For anyone watching in the future: clicking the stop button in the home tab does not fire the PlayerRemoving event anymore. In order to test the script, go to the test tab and start a server. Close out on the player's tab and then you should see the data saved message in the output.
I love how he doesnt just say, "Copy the script" He explains it so it does not just help us in datastores it helps us understand other scripts and what types of functions we need. It also helps us understand what were typing.
@@snoanashi1597 Id just like to interject for a moment what you are referring as "Lua" is in fact Luau, Roblox stopped using Lua5.1 some time ago and now it uses a "modified" version of it made from scratch by Roblox that they called Luau, many functions and even operators that you use in Roblox will not work in actual Lua.
Devking, i found you from your channel "TapWater" and watched one of your "current" videos which is your scripting our goofy ideas. Just when i thought, "okay, im a bad scripter and only know the basics and mostly just copy off scripts", you came in clutch and made me ACTUALLY LEARN all this advanced stuff of datastores, lerping, CFrame and i actually feel like an actual scripter. I just want to say thank you for what you're doing.
@@Bryce_TBS_Films you can do it, its not very hard. You can store the assets in replicated storage and give them a unique key and then save those keys in datastore.
Edit: After 3 long years of rewatching this tutorial and other tutorials, I've finally understood the concept of datastores. thanks buddy. I can now move on to the next scripting episode
@Circuit Master im a pretty good scripter when it comes to certain things, but theres still a lot more for me to learn. not a single thing ive learnt has come from alvinblox, though. any time i try to learn something from him i fail and end up learning it somewhere else. a year ago i tried learning how to script, saw that alvin was popular and tried learning from him but ended up giving up. one day, someone recommended me peasfactory who ended up teaching me everything i needed to know to understand roblox lua. alvin barely taught me variables.
@@mool487 the way i do it is, first i watch thedevking tutorial, and if i didn't understand his tutorial THEN ill go to alvinblox's tutorial. A lot of times devking leaves out a lot of details that i want or need to know, so my two options are 1. watch a shorter video of thedevking underexplaining the lesson but getting the point across or 2. watch an unreasonably long video of alvinblox explaining what i need to know and then re-explaining and overexplaining it 65 more times
Bro, I was so fucking burnt out from scripting and couldnt understand ANYTHING and I found you from a recommendation and I'm actually getting somewhere now. ur so chill and following with you and learning with u is so easy bro so tysm I think I have hope in myself now bro 😭😭
If you guys are making a game where every click or something is updating the leaderboard by +1 every click or something along the line, make sure if its a local script, you use the fireserver commands in order to send the new score to the server
I know I am a bit late, but I just wanted to say that I love how you go in depth and actually explain what each function means and does rather than just telling us what to type and leaving us confused. I love your work, please never stop uploading! ♥
Watch the beginner series first its very helpful and leads into understanding this video fully. As a person who has watched all his beginner videos, those videos are a MUST WATCH
@@dzleandrew4544 If you need some clarifications, let me know. I can show you how to understand programming languages from the core. Once you understand how computers "understand" code, you can learn any programming language in 2 seconds. The computer science concepts will always remain the same, it's just the syntax that changes.
one small mistake in the video, in the PlayerAdded function , when you're setting the local data variable, you need to set it as a table, so that multiple values can be saved into it. Instead of declaring it as 'local data', you need to declare it as 'local data = {}'
@@shortstorysforall I just see it as, you’re saving an empty single value if you just have one thing in the datastore, but since you have multiple which gets saved as a table, you then have to save an empty table to put values into
If you want to save a players objects, for example if they have a sword, or if they own a pet etc. you cannot do it in this way, instead you should make a value for it (i.e create a bool val inside the player) and save that value when the player leaves. You can then check that value when the player rejoins and give that item back. I learned this the hard way lol...
For weapons u can also put a folder in the player and save all those weapons there and when a player joins the game you can make a script to give them all weapons in folder
MyName IsPrivate well yes, but that doesn’t really explain how to save it. I explained this because no matter where I looked it was near impossible to find a video on how to save instances so I spent ages experimenting and using tips from other people and made this way, idk if it exists and if I just didn’t find it, but the good thing is, I am now an expert at datastores and know basically everything about it lol. Regarding your way, I’m not sure if ur referring to tools, and if u mean put tools in the backpack, is that what you meant?
If you were to watch his tutorials you are not ready for Data Store, people doesn't know UserId, they don't understand it. TheDevKing goes right to the point without explaining each event and function to do this.
@Poseidon Neptune yup. Dont worry anout memeorizing it but make sure you know what the script does and what it is used for. Datastores are used to save your data
By the way, changing properties of "Cash" is local. You need to use the developer console to do it on the server. Press F9 to open it. I hope I helped some people 😉
Big thanks to you! Your tutorial series has really helped me in Roblox development! I am to a point where I can do a lot of things by myself! I've been making games in Roblox for 3 years and I spent 1 year actually learning from tutorials! Heh, oh boy I should have done what I'm doing now from the start. Would not have been so bad if I actually looked over tutorials instead of stealing scripts! :>
For everyone saying "It doesn't work" It did just work for me, you most likely did something wrong. Take a good look at your output and fix the errors or just recheck your script. Edit: Also make sure you only have 1 leaderstats folder under the player. If theres 2 or more it means you have other active scripts running that are also creating leaderstats
THANK YOU SO MUCH. So I had a data saving script, and the reason it wasnt working was because when i was setting my data i was setting it on the client instead of the server, you are amazing, thank you!
10:15 Async means Asynchronous. This is the opposite of Synchronous and it will wait to assign the variable till it gets it and wont do this at the same time as your game is running, it will do it on its own time and get back to you when it has it.
I know this is a old comment, but incase anyone else see's this and gets confused like I did. From my understanding of just researching it to make sure this comment was true, it actually yields the process until the data has been retrieved.
Me: **Following instructions to perfection because I already rewrote the datastore 5 times** TheDevKing: Now press play to test. **Script works** Me: **Presses play to test** My script: *Haha funni game go brrrrrr*
@@thatrobotguy7963 still got the code script? cuz i wanna go over it and i see what i did wrong since i keep checking everything and i dont see a problem in it and my error message wont give me anything that is a actual error message except the one telling me that i got a error in my script
Async actually means asynchronous. When an async function is called it will run on a different thread. Async has nothing to do with synchronization like the way you mentioned it.
For me, it doesn't work. The code never gets to the point of printing "Data successfully saved" or "There was an error". I tested the code, and for some reason, the code gets stuck at these lines: local success, errormessage = pcall(function() levelDataStore:SetAsync(playerUserId, data) (yes i want to save levels that is why its level data store) end) I have no idea what i did wrong, i have rewritten the script multiple times already. And to top it all off, the code actually works with like a 1/5 chance of success so i am lost. If you could help with this, i would appreciate it!
If it is a string value, then it wont work. You cat datastore stringValues, but you can Set datastores to strings, Id recommend you read this: developer.roblox.com/en-us/api-reference/function/GlobalDataStore/SetAsync
See this is my problem, you say that if I don’t understand it I have to watch the beginners, but the thing is, I understand it, I watched it, but I don’t remember it.
Jerick Octaviano Check so that you did exactly as in the video and when your currency valu change in the game make sure that it changes in the server not on the client due to filtering enabled with stops players from hacking their money in your games hope this helped
Really appreciate this video - Hugely educational. Anyone ever figure out the cause of the error he received? Very frustrating that the response was something like "OK, ummm...yea...I'm just going to ignore it." I follow this exactly, I get an error on the exact same line, and my script doesn't run.
Hey, I was having problems with mine loading data until I added the 2nd parameter. Which I think is a newer feature data = myDataStore:GetAsync(playerUserId, cash)
you probably found the problem but you have to call the "cash" or anything else. for example if cash is member of leader stats them write "leaderstats.Cash" just call it
could you make a video on how to create a script that changes other values and saves it worldwide on player's actions? for example: a ban system but you can ban players without that player being in the game. in my thought, you would need to create a value and save the value to stay there for all servers. how would i do that?
Ahahaha I finally did it!!! I finally managed to save my leaderstats and from what I realised from this video, I can save anything!!! Ty very much your video was awesome and very usefull. Other youtube videos about this subject did not teach me anything, plus they didn't even work. I wanna thank you sooooooo much. I hope you have a great life!
local datastoreservice = game:GetService("DataStoreService") local mydatastore = datastoreservice:GetDataStore("mydatastore") local data game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local XP = Instance.new("IntValue") XP.Name = "XP" XP.Parent = leaderstats local PlrId = "Player_"..plr.UserId local success, errormessage = pcall (function() Data = mydatastore:GetAsync(PlrId) end)
if success then XP.Value = Data --load things end end) game.Players.PlayerRemoving:Connect(function(plr) local PlrId = "Player_"..plr.UserId data = plr.leaderstats.XP.Value local success, errormessage = pcall(function() mydatastore:setAsync(PlrId, data) end) if success then print("Data Saved") else warn("Error! "..errormessage) end end)
can you do multiple datastore? Like theres a cash datastore, theres a vehicle datastore a datastore for storing vehicles you've bought/earned. EDIT: I watched the entire video. You made it a table for multiple data to be saved.
hey i know im 5 days late did you figure out your game? im trying to do the same for over 3years now im too dumb to understand i always fail could you share please?
So the script may not work for some of you, so my solution is that you should create a script in your leaderstats (have no data stores in leaderstats). Here's the script: local Players = game:GetService("Players") local DataStoreService = game:GetService("DataStoreService") local Saver = DataStoreService:GetDataStore("SaveLeaderstats") Players.PlayerAdded:Connect(function(player) local Data = nil local success, errormessage = pcall(function() Data = Saver:GetAsync(tostring(player.UserId)) end) if success then if Data then for i, v in pairs(Data) do if not player:FindFirstChild(i) then player:WaitForChild("leaderstats"):WaitForChild(i).Value = v else player:FindFirstChild(i).Value = v end end end else error(errormessage) end end) local function Save(player) local SavedData = {} for _, v in pairs(player.leaderstats:GetChildren()) do SavedData[v.Name] = v.Value end for _, v in pairs(player:GetChildren()) do if v:IsA("IntValue") then SavedData[v.Name] = v.Value end end local success, errormessage = pcall(function() Saver:SetAsync(tostring(player.UserId), SavedData) end) if not success then error(errormessage) end end Players.PlayerRemoving:Connect(Save) game:BindToClose(function() for _, v in pairs(Players:GetPlayers()) do Save(v) end end)
you can also do: local success, data = pcall(datastore.GetAsync, datastore, playerUserId) and it will be the same thing but it will be shorter and you will have a local variable
ngl I doubted this tutorial I thought it wasn’t good. But after hours of confusion I was really desperate so I clicked on the tutorial and it cleared so many things up. Obviously there are some mistakes but you have helped me a lot
So yea I know nothing about coding, but this actually explained alot and I have a working data store. And I'm good with changing the values now so I can actually make it what I want
For anyone watching in the future: clicking the stop button in the home tab does not fire the PlayerRemoving event anymore. In order to test the script, go to the test tab and start a server. Close out on the player's tab and then you should see the data saved message in the output.
you saved me a lot of time... thank you
thanks bro
Thanks!
Thanks so much!
Thnx
I love how he doesnt just say, "Copy the script" He explains it so it does not just help us in datastores it helps us understand other scripts and what types of functions we need. It also helps us understand what were typing.
"Copy the script and go away" - Probably me when I learn everything in Lua
@@HarryDKH thats like saying just go and repair a pipe with with a picture of the plug being fixed
@@HarryDKH yeah i spelt some stuff wrong but it doesnt explain but without actually knowing how to do it
@@snoanashi1597 Id just like to interject for a moment what you are referring as "Lua" is in fact Luau, Roblox stopped using Lua5.1 some time ago and now it uses a "modified" version of it made from scratch by Roblox that they called Luau, many functions and even operators that you use in Roblox will not work in actual Lua.
@@lyfranklin6418 there’s a difference between a pipe and programming
Devking, i found you from your channel "TapWater" and watched one of your "current" videos which is your scripting our goofy ideas.
Just when i thought, "okay, im a bad scripter and only know the basics and mostly just copy off scripts", you came in clutch and made me ACTUALLY LEARN all this advanced stuff of datastores, lerping, CFrame and i actually feel like an actual scripter. I just want to say thank you for what you're doing.
dont feel like an actual scripter, u r already an actual scripter :D
@@MdMuq thanks :) You are too!
@@MdMuq nice guy fr
@@MdMuq i still dont know how to use CFrame after 2 month of learning
Just got back from High School to see a video by Dev King, usually means my nights going to be good
Never been more right
sus
It has been 4 years you done with high school bro
@@randomguy3002 lololololololollo
Thanks man, I'm more of a visual and auditory learner and this helped a lot. Much appreciation :)
So glad it could help :)
@@TheDevKing Do you think you could show us how to compress data and how too save models and stuff into the Data store system, Thanks and good video.
@@Bryce_TBS_Films you can do it, its not very hard. You can store the assets in replicated storage and give them a unique key and then save those keys in datastore.
@@Bryce_TBS_Films google it
the only way to learn is with sight or listening besides brail
I just watched your video on CFrame, you’ve just earned a new subscriber!
Edit: After 3 long years of rewatching this tutorial and other tutorials, I've finally understood the concept of datastores. thanks buddy. I can now move on to the next scripting episode
bruh
3 years.... to move to the next episode..... (meanwhile me watching 3 of em a day and getting the basics remembered lol)
Help I did everything in the tutorial and it doesnt work
7:34 me when I look at my bank account
good me
lmao 😂
LMFAO
When i look and see i dont even have a bank since im too poor
@@momocraft365 jus say you're underage bro
19:10 "if the data saves sexually, oh god, that's not what I said" lmaooooo
LOLOLOLOLOLOLOLOLOLOLOL
What was on his mind? lol
Bruh you cant use socks like datastore
Lol
datasores store: type of sex, length of sex, good or bad sex (bool value)
These videos are the only good scripting tutorial vids because I can understand him, and he tells us more detail then others.
@Circuit Master not at all
@Circuit Master im a pretty good scripter when it comes to certain things, but theres still a lot more for me to learn. not a single thing ive learnt has come from alvinblox, though. any time i try to learn something from him i fail and end up learning it somewhere else. a year ago i tried learning how to script, saw that alvin was popular and tried learning from him but ended up giving up. one day, someone recommended me peasfactory who ended up teaching me everything i needed to know to understand roblox lua. alvin barely taught me variables.
@Circuit Master i guess we learn stuff differently
@@mool487 the way i do it is, first i watch thedevking tutorial, and if i didn't understand his tutorial THEN ill go to alvinblox's tutorial. A lot of times devking leaves out a lot of details that i want or need to know, so my two options are 1. watch a shorter video of thedevking underexplaining the lesson but getting the point across or 2. watch an unreasonably long video of alvinblox explaining what i need to know and then re-explaining and overexplaining it 65 more times
@@mool487 same lol
just got an ad saying that if i wanna get good at coding, stop with youtube tutorials. they clearly have never seen this mans channel.
bro dont apologize for long videos. if its 30 minutes long like this video was, that means its very helpful since we get all the details.
It took me 2 days to realize that i forgot to turn on api services
R I P
F
F in the chat
F
@@musicb_77 f
Bro, I was so fucking burnt out from scripting and couldnt understand ANYTHING and I found you from a recommendation and I'm actually getting somewhere now. ur so chill and following with you and learning with u is so easy bro so tysm I think I have hope in myself now bro 😭😭
If you guys are making a game where every click or something is updating the leaderboard by +1 every click or something along the line, make sure if its a local script, you use the fireserver commands in order to send the new score to the server
TYSM this helped me sooooo much
Leaving my reply here so that if I get stuck on a similar issue, I can come to this comment and understand it. Thanks!
oh nice
I thought my scripting lessons were over man.. thanks
Now we know that TheDevKing is aroused by saving and loading data. We understand u
facts
Lol
lmaooo
I know I am a bit late, but I just wanted to say that I love how you go in depth and actually explain what each function means and does rather than just telling us what to type and leaving us confused. I love your work, please never stop uploading! ♥
I mean he kinda did explain it.. just not clear AHAHHAA
Watch the beginner series first its very helpful and leads into understanding this video fully. As a person who has watched all his beginner videos, those videos are a MUST WATCH
the forshadowing :C
@@dzleandrew4544 If you need some clarifications, let me know. I can show you how to understand programming languages from the core. Once you understand how computers "understand" code, you can learn any programming language in 2 seconds. The computer science concepts will always remain the same, it's just the syntax that changes.
@@angry_moose94 I’m interested.
"Poofect!"
That was adorable.
one of the best tutorials out there, thx for explaining every single bit, its way more clear now, thx again
Has been 4 years yet this tutorial is still the best
22:07 dev king said "boom!", but i went "YES IT SAVED, I MADE A SAVE! THIS IS GROUNDBREAKING!" and i went crazy
ok
ok
one small mistake in the video, in the PlayerAdded function , when you're setting the local data variable, you need to set it as a table, so that multiple values can be saved into it. Instead of declaring it as 'local data', you need to declare it as 'local data = {}'
what? my problem is that wins and cash are the same value
@@myusernameskitty1230 that's what he just explained
can you be a bit more clear, you said you need to put the values in a table but how are you meant to do like local Values = {
Cash.....
Gem.....
}
@@shortstorysforall its like a normal local but when you want to use either gems or cash you have to do Values.Cash or Values.Gem
@@shortstorysforall I just see it as, you’re saving an empty single value if you just have one thing in the datastore, but since you have multiple which gets saved as a table, you then have to save an empty table to put values into
3 years later, still never gets old
3 years and 3 months later, still never gets old
@@AstralScript ok
@@AstralScript 3 years, 3 months, and 11 days later, still never gets old
@@East9211 3 years, 3 months, and 18 days later, still never gets old
3 years and 5 months later, still never gets old
If you want to save a players objects, for example if they have a sword, or if they own a pet etc. you cannot do it in this way, instead you should make a value for it (i.e create a bool val inside the player) and save that value when the player leaves. You can then check that value when the player rejoins and give that item back. I learned this the hard way lol...
Oh thanks for the explanation
Lol yeah that’s probably the easiest way to do it
For weapons u can also put a folder in the player and save all those weapons there and when a player joins the game you can make a script to give them all weapons in folder
MyName IsPrivate well yes, but that doesn’t really explain how to save it. I explained this because no matter where I looked it was near impossible to find a video on how to save instances so I spent ages experimenting and using tips from other people and made this way, idk if it exists and if I just didn’t find it, but the good thing is, I am now an expert at datastores and know basically everything about it lol.
Regarding your way, I’m not sure if ur referring to tools, and if u mean put tools in the backpack, is that what you meant?
@@TapWaterRBLX I heard that thedevking stole ur play button. Did you get it back?
I Would need to Watch This 100 times to learn and remember it
If you would it would take over 2 days if you watch 24 hours a day... In that time you could've made a whole game!!!
If you were to watch his tutorials you are not ready for Data Store, people doesn't know UserId, they don't understand it. TheDevKing goes right to the point without explaining each event and function to do this.
@Poseidon Neptune yup. Dont worry anout memeorizing it but make sure you know what the script does and what it is used for. Datastores are used to save your data
@@SaxePrixon Did you Just replied to your own comment?
@@Spelo1 probably lol
By the way, changing properties of "Cash" is local. You need to use the developer console to do it on the server. Press F9 to open it. I hope I helped some people 😉
5 months late but you can say /console too!
Mmaxo 2 years late and I have nothing to say lol
@@kepiblop 2 years and 5 months late and i also have nothing to say
@@roatninthethird 100 years late and i like anime
inf years late and im glitched
Big thanks to you! Your tutorial series has really helped me in Roblox development! I am to a point where I can do a lot of things by myself! I've been making games in Roblox for 3 years and I spent 1 year actually learning from tutorials! Heh, oh boy I should have done what I'm doing now from the start. Would not have been so bad if I actually looked over tutorials instead of stealing scripts! :>
this is the hardest thing he has ever taught me
dude i was trying to save Cash and XP but i couldnt seem to know how to do it so i watched this video and you basically showed me and tot me! thank
4 months of scripting, this is the 13th time revisting this video -_-
3:24
"Basically you're getting a DataStore" - TheDevKing 2019
@@TBHfaneto ohhh right
I love when he repeats stuff
@@nineveh17 ok
DAMN BRO EXTREME THUMBS UP ON EVERY ONE OF YOUR VIDEOS I SEE FROM NOW ON THIS HELPED ME SO MUCH TYSM
Really simple tip, but when you are Instancing, you can add a comma and then whatever you put after that will be the parent. Great Vid :)
No, don't do this. That is a lot slower than just giving it a parent after the instance is created.
@@Simvoid230 I mean who cares about speed 🥱
It's just a bit more convenient
Thank you soo much for this tutorial. I had so much problems with saving data, watched all possible tutorials, but no one of them helped.
THANK YOU SO MUCH I FINALLY GOT THIS TO WORK THANKS TO YOU!
i spendt 2 months feeling demotivated because i couldnt figure out how to save multible variables, thank you very much!
Did you watch the tables video
What are you guys going to use DataStore for? Personally, I’m going to use it to save a player’s cars by using bool values.
Gonna be using it for a fantasy rpg I plan to make but I still have more to learn before I do it
I need to save my stando's from my jojo game
for my difficulty chart obby
gun saves, but rn it aint workin
This is the best tutorial I could find, I've been making games without datastores for so long (just because I couldn't find a good video)
THANK YOU
Thank you soo much for this tutorial I have literally been trying to do this on off for atleast 2 years and your tutorial was a great help!
5:41 "We're gonna go ahead and go ahead"
For everyone saying "It doesn't work" It did just work for me, you most likely did something wrong. Take a good look at your output and fix the errors or just recheck your script.
Edit: Also make sure you only have 1 leaderstats folder under the player. If theres 2 or more it means you have other active scripts running that are also creating leaderstats
lmao only comment that isnt from years ago
THANK YOU SO MUCH. So I had a data saving script, and the reason it wasnt working was because when i was setting my data i was setting it on the client instead of the server, you are amazing, thank you!
10:15 Async means Asynchronous. This is the opposite of Synchronous and it will wait to assign the variable till it gets it and wont do this at the same time as your game is running, it will do it on its own time and get back to you when it has it.
I know this is a old comment, but incase anyone else see's this and gets confused like I did. From my understanding of just researching it to make sure this comment was true, it actually yields the process until the data has been retrieved.
Thanks 30 minutes ago i had no idea what DataStores are and How to save players data But now i do!
Me: **Following instructions to perfection because I already rewrote the datastore 5 times**
TheDevKing: Now press play to test. **Script works**
Me: **Presses play to test**
My script: *Haha funni game go brrrrrr*
@ItzEthan I fixed it like a couple of hours later, it is really finicky.
@@thatrobotguy7963 I know it’s been 9 months but do you remember what you did?
@@tigerthegreat9912 Make sure you spell things correctly
@@thatrobotguy7963 Ok ill check. Fast response btw.
@@thatrobotguy7963 still got the code script? cuz i wanna go over it and i see what i did wrong since i keep checking everything and i dont see a problem in it and my error message wont give me anything that is a actual error message except the one telling me that i got a error in my script
OMG THANK U SO MUCH, ive tried so many other tutorials and they havent worked but yours has! thanks man
Async actually means asynchronous. When an async function is called it will run on a different thread. Async has nothing to do with synchronization like the way you mentioned it.
Mb getasync just means get a sync?
YAY, UR THE BEST, I HAVE TRIED FOR 2 MONTHS, FINALLY!
Omg you made new video. Can you make weekly vids??
First roast lol.
im gonna try to do 3 per week
Nice
@@TheDevKing wow thanks
Appreciate it man! Your tutorials are the best!
yoo kash wsg!
I feel like a three year old while watching this.
why?
i dont remember why lol
Yelezi cuz of the guys voice
lolol
LMFAOOO
NICE I'VE BEEN WAITING THANK YOU SO MUCH
I was so worried about DataStores because they look super complicated but this made it a lot easier to understand!
HOW IS THYIS NOT HARD
@@Nutsaq2222 I find it so hard to memorize it
@@linartulaj3588 don't memorize it
ur scripting vids help so much :D
For me, it doesn't work. The code never gets to the point of printing "Data successfully saved" or "There was an error". I tested the code, and for some reason, the code gets stuck at these lines:
local success, errormessage = pcall(function()
levelDataStore:SetAsync(playerUserId, data)
(yes i want to save levels that is why its level data store)
end)
I have no idea what i did wrong, i have rewritten the script multiple times already.
And to top it all off, the code actually works with like a 1/5 chance of success so i am lost. If you could help with this, i would appreciate it!
Try to test it in the actual game instead of using roblox studio, that's what fixed my problem :)
@@78bikerchick Thanks so much, that worked for me too!
If it is a string value, then it wont work. You cat datastore stringValues, but you can Set datastores to strings, Id recommend you read this: developer.roblox.com/en-us/api-reference/function/GlobalDataStore/SetAsync
@TrizCoid thank you, i was wondering why it wasnt working xD
love what youre doing, your amount of talking does test my patience tho lmao, but keep it up G, im not telling you to change anything
Can anyone help? The script works fine with a single variable but not when I put in a table. It says attempt to index number with number
same issue
YAAASSS IT WASNT WORKING BEFORE IN STUDIO BUT WHEN. PLAYED MY GAME IN ROBLOX IT WORKS THANK YOU SO MUCH
I've seen this like 10 times.
I still can't understand, so this is it
bRUH
same but ill figure it out eventually
Congrats man I subbed from when you where 10k
The comments pretty new though
"Get a sink"
LOL
“Sink the data”
This was the best tutorial ever.
See this is my problem, you say that if I don’t understand it I have to watch the beginners, but the thing is, I understand it, I watched it, but I don’t remember it.
Practice makes perfect that is litteraly what i struggle with too
Congrats on 400K
every developer's worst nightmare..
and pathfinding
@@Dogey_Dogger lmao
This was the only tutorial i understood about Data Store, tysm!
It's very hard to learn dataStores.
there is no error on output and when i leave it says "Data Successfully save!" and when i play again the data not saving. Please help
Data does not save in studio, you need to make your game public and play like that
Sorry for the late reply
Turn on api in studio and make sure you have internet. If you have api turned on it will save from studio
The Dreaming Journal doesn’t matter he will get an error if API isn’t enabled
Jerick Octaviano Check so that you did exactly as in the video and when your currency valu change in the game make sure that it changes in the server not on the client due to filtering enabled with stops players from hacking their money in your games hope this helped
i think you changed the cash while in client mode
I've watched 3 different vids that worked but didn't help me understand it then I remembered you probably know, thanks for this video.
Really appreciate this video - Hugely educational. Anyone ever figure out the cause of the error he received? Very frustrating that the response was something like "OK, ummm...yea...I'm just going to ignore it." I follow this exactly, I get an error on the exact same line, and my script doesn't run.
He gave you a solution. Did you try if data then?
Good video! Thanks for your help with coding. :D
[19:12] "if the data saves sexually" 🙏😭
Time to enjoy!
Hey, I was having problems with mine loading data until I added the 2nd parameter. Which I think is a newer feature
data = myDataStore:GetAsync(playerUserId, cash)
Is your cash variable capitalized? If it is, then capitalize cash
you probably found the problem but you have to call the "cash" or anything else. for example if cash is member of leader stats them write "leaderstats.Cash" just call it
thank you so much that worked
Great tutorial 👍👍🏿
could you make a video on how to create a script that changes other values and saves it worldwide on player's actions?
for example:
a ban system but you can ban players without that player being in the game. in my thought, you would need to create a value and save the value to stay there for all servers.
how would i do that?
game.Players.PlayerAdded:Connect(function()
if player.Name == "PlayerName" then
player:Kick("reason")
end
end)
@@beedrillking4023 he can just change his name. Getting his id and banning/kicking him when he joins should be better
@@practicalcucumber1395 yup 4 months ago i was an idiot
Bro u are the best u explain everything,hope you the best
LMAO HE SAID "Sexually" LMFAOOOOoOoOooOoOo
Necrowave wait what when lol
@@TapWaterRBLX 19:10 "if success so if the data saves sexually succes- oh god" turn on captions xd
yeah sexually is so funny guys. lmao cant stop wheezing
devking is aroused by saving data
Ahahaha I finally did it!!! I finally managed to save my leaderstats and from what I realised from this video, I can save anything!!! Ty very much your video was awesome and very usefull. Other youtube videos about this subject did not teach me anything, plus they didn't even work. I wanna thank you sooooooo much. I hope you have a great life!
27:00
Took u 7 and a half years to learn that jeez 😒 I have the utmost respect ✊ for that resilience
Thanks Dad
Dad what are you doing is this how you make money
stop bullying my teacher dad
Very helpful! Thank you, Devking.
im having problems with line 30
game.Players.PlayerRemoving:Connect(function(player) can you paste the whole script in description?
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("mydatastore")
local data
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Parent = leaderstats
local PlrId = "Player_"..plr.UserId
local success, errormessage = pcall (function()
Data = mydatastore:GetAsync(PlrId)
end)
if success then
XP.Value = Data
--load things
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local PlrId = "Player_"..plr.UserId
data = plr.leaderstats.XP.Value
local success, errormessage = pcall(function()
mydatastore:setAsync(PlrId, data)
end)
if success then
print("Data Saved")
else
warn("Error! "..errormessage)
end
end)
@@WoahItsKris did that work for you?
@@taibarrett1st Yeah, you might have to fix a little of it though.
i was so close to giving up i even stoped watching but then i got my mind focused and finished the vid
thank you for the awesome vids btw
Hmmm…what if I am making a “Find The Items” game and I need to save the items to the inventory?
@M.A green cube Gaming im his cat🐱
Thanks for the tutorial. I'm getting more familiar with Lua by watching your vids.
Is this outdated?
Thanks dude, you saved me from trial and erroring the entire thing.
can you do multiple datastore? Like theres a cash datastore, theres a vehicle datastore a datastore for storing vehicles you've bought/earned.
EDIT: I watched the entire video. You made it a table for multiple data to be saved.
hey i know im 5 days late did you figure out your game? im trying to do the same for over 3years now im too dumb to understand i always fail could you share please?
@@sintulichao3066 watch the video
"So this is GetASync, what it means is..... GetASync" Nice.
27:10
7 1/2 years and a few seconds
Doctor: You have only 29 minutes to live.
Me:
"stick that bad boy in there" lmaoo sound wrong
ajwkdflsdasdf
Multiple sexual remarks made in the making of this video
After he said sexually
Really annoying how he kept deleting and undoing making it way more complex but I really do appreciate the video 😭
So the script may not work for some of you, so my solution is that you should create a script in your leaderstats (have no data stores in leaderstats). Here's the script:
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local Saver = DataStoreService:GetDataStore("SaveLeaderstats")
Players.PlayerAdded:Connect(function(player)
local Data = nil
local success, errormessage = pcall(function()
Data = Saver:GetAsync(tostring(player.UserId))
end)
if success then
if Data then
for i, v in pairs(Data) do
if not player:FindFirstChild(i) then
player:WaitForChild("leaderstats"):WaitForChild(i).Value = v
else
player:FindFirstChild(i).Value = v
end
end
end
else
error(errormessage)
end
end)
local function Save(player)
local SavedData = {}
for _, v in pairs(player.leaderstats:GetChildren()) do
SavedData[v.Name] = v.Value
end
for _, v in pairs(player:GetChildren()) do
if v:IsA("IntValue") then
SavedData[v.Name] = v.Value
end
end
local success, errormessage = pcall(function()
Saver:SetAsync(tostring(player.UserId), SavedData)
end)
if not success then
error(errormessage)
end
end
Players.PlayerRemoving:Connect(Save)
game:BindToClose(function()
for _, v in pairs(Players:GetPlayers()) do
Save(v)
end
end)
Nice :) you are funny sometimes and i like that i enjoyed this video yea and thanks for everything it works :))
Íncrivel! Queria que estivesse em português mas mesmo assim está ótimo. Muito Obrigado! 👍👏
it means
Incredible! I wish it were in Portuguese but it's still great. Thank you so much!
@@timmyismyfavoriteidol Yes
Great tut DevKing... lol I almost thought my script didn't work, i am getting this!
change local leaderstats = Instance.new("IntValue") by local leaderstats = Instance.new("IntValue", player)
you can also do:
local success, data = pcall(datastore.GetAsync, datastore, playerUserId)
and it will be the same thing but it will be shorter and you will have a local variable
ngl I doubted this tutorial I thought it wasn’t good. But after hours of confusion I was really desperate so I clicked on the tutorial and it cleared so many things up. Obviously there are some mistakes but you have helped me a lot
Can you do one for a base so players in my game can save their base’s
So yea I know nothing about coding, but this actually explained alot and I have a working data store. And I'm good with changing the values now so I can actually make it what I want