Saving Player Data with Data Stores! Roblox Studio Simulator Guide Episode 2
HTML-код
- Опубликовано: 24 июл 2024
- In this Roblox Scripting Tutorial, we continue creating our Roblox Simulator! Today we go over saving Player Data using Data Stores from the Roblox API!
Subscribe for more Roblox Scripting Tutorials!
Join my Patreon to support me and gain access to the Scripts in this video! / monzterdev
Download the Scripts from this video here:
/ 70326146
Download the Game file from this video here:
/ 70326232
Here is the Auto-Scale Lite Plugin I used for the GUI:
devforum.roblox.com/t/plugin-...
0:00 Intro
0:56 Publishing the Game to Enable DataStores
1:24 Settings up the DataStore
2:48 Creating the Player Setup Function
9:14 Creating the Player Save Function
13:05 Testing the Data Store
14:42 Creating the On Shutdown Function
19:25 Testing Saving & Loading Data
20:15 Creating an Auto Save function
23:00 Loading all Players Data on Startup
23:31 Creating Request Budget Function
26:11 Verifying everything is Working
27:26 Outro
The Simulator we're using for reference is Eating Simulator:
www.roblox.com/games/69532914...
➜Join my Discord monzter.dev/discord
➜Follow me on Twitter @MonzterDev / monzterdev
➜Support me on Patreon / monzterdev
Business Email: MonzterSlayer4@gmail.com
#Roblox #RobloxDev #RobloxScripting
Hey if you guys need help, I'd recommend joining our community Discord! Lots of others are in there who have had similar issues, so join here: discord.gg/learnroblox
You can also download the game file from my Patreon here: www.patreon.com/posts/70326232
@BurakTPC™ 2͜͡ シ-- #wednesday i have the same problem
@FalkonPlayz Same
Not Saving My Data
same
so when i put the whole code everything i test the game put my numbers dont go up please tell my why im crying please.
Now this is what I call "Proper tutorials". Super In-depth but easy to understand, this has it all. Lots of good luck and well done! I am following this tutorial to make a good game.
I'm really glad you enjoy it, thanks for the kind words :D
@@MonzterDEV nah man you deserve it :D
do you know how to make the words grey while your scripting on pc?
@@SlappedYTT ctrl + /
@@SlappedYTT just do -- after ur line of script to type
below the print(returnValue) area, make sure it says ~= nil, NOT == nil, please check this if your data won't load
thank you now it works
can u give me the full script
@@geo_sailor dont be lazy
btw thanks for this, now it fully works
@@geo_sailor I'm not so comfortable sending you the entire thing. But here's the part I'm mentioning
print(returnValue)
sugar.Value = if returnValue.Sugar ~= nil then returnValue.Sugar else 0
coins.Value = if returnValue.Coins ~= nil then returnValue.Coins else 0
gems.Value = if returnValue.Gems ~= nil then returnValue.Gems else 0
Please note that "food" is replaced with "sugar", and I've added a third currency, that being the "gems".
Sorry for the late reply.
Been absolutely loving this series! It's been helping me learn so much and I'm doing one episode every day! You're truly a legend, and you're criminally underrated!
Really glad you're enjoying! Thank you so much for the kind words :D
@@MonzterDEV Could you help me? Currently there is an error not letting me save my data saying "UserID is not a valid member of Player "Players.(MyUser)"
@@eggesons9547 Type UserId not UserID
@@Nidex1 Thank you, you saved me!
Thank you so much i had the same problem i could not see that it was UserId
Wow I’ve seen a lot of tutorials for simulators but none are as good as this one I’m shocked you don’t have more subs because I needed tutorials like this one! Keep up the good work
Thanks for the kind words! I try my best :D
your tutorials are SO GOOD!!! u explain it so well and it's so easy to follow. You deserve so many more subscribers!
Thank you! I'm glad you're enjoying them :D
do you know how to make the words grey while your scripting on pc?
u must do those lines on the words to make them grey if u know what I'm talking about
This is the definition of a good tutorial which explains everything.
Aw, thank you! I’m happy to hear that!!
OMG THX SO MUCH I WATCH LIKE 4 OTHER VIDEOS BUT THEY DID NOT WORK FOR ME BUT THIS ONE DID!!! YOU A LEGEND!!!!
Thank You sooo Much I wanted to be a roblox dev and your helping me reach that goal! You Have earned A sub
I AM SO MAD.. that you currently only have 5000 subscribers, i dont get it. You are so good at scripting. You have a great mic. Your scripting skills are top. Why only 5000? You have helped me so much! Ty
Aw thanks! Hopefully by the end of 2023, we'll have 5 million :P
Keep up the good work!
Im learning so much from you!
Thanks! I'm glad :D
do you know how to make the words grey while your scripting on pc?
@@SlappedYTT Just Add 2 dashes before the script line
Insane tutorial. Thank you so much, your clear explanations and videos are helping me build an awesome game! You earned a sub and a like!
Thanks so much for taking the time to leave the comment! Glad it helped :D
This video is awesome! the way you explained everything was good and helped me out a lot keep up the amazing work! you deserve more subscribers you are very underrated.
Thanks for the feedback and kind words! Really glad it helped!
@@MonzterDEV when i was scripting all the data thing script , the leaderboard broke and it doesn't show , any idea of what might have caused it?
i think the data script might have broken the leaderboard script , it is possible to make another script on ServerScriptService where the leaderboard script is transferred?
do you know how to make the words grey while your scripting on pc?
Thanks it helped me a lot when I was struggling on how to find a concept of a game and the coding.
And I subscribed
Glad it helped ya, welcome!
Keep up the good work!👍
Best Tutorial! Easy To Follow And Thanks For Explaing Each SCript, Other Tutorials Dont Say What They Do. Thanks!
Really glad you enjoyed and were able to learn from it!!
do you know how to make the words grey while your scripting on pc?
Before I had a comment or saying i had an issue. I have fixed it and this tutorial is AWESOME W mans
How did you fix it
For the people confused why the table is printing random letters and numbers is because you need to turn off "Log Mode" in the three dots on the top right of the output screen
Thank you so much. I have always wondered why my table was just showing random letters and numbers. Thank you agian.
Where I don’t see it
Thanks! Really helped with my game.
Glad it helped!
What i'm looking for! Thanks man
Enjoy!
If you create a course making a FULL game from start to finish and explaining things like you did in this. Aswell as gamepasses and all that and 3d renders. I will buy it. You sir really know what you are talking about. I can't wait to learn a lot from you
Thank you! I hope you enjoy the series!
do you know how to make the words grey while your scripting on pc?
add two "-" before the line
e.g:
--script.parent.text = "This is so cool"
Nice video!
you deserve 1 million subscribers that really helped me
Aw, thanks! Glad it helped 😃
@@MonzterDEV :D
@@MonzterDEV the dumb thing is that am french so i cant understand very much🤔
Hello, i have a problem. When i start the experience it say me "Attempt to connect failed: Passed value is not a function" but i don't know how to fix it i tried everything i can but i didn't found i just know one thing : When i suppr Players.PlayerRemoving:Connect(save) the error message is not here but without it i can't keep the data. Ty if you can help me !
Thanks, I had so many problems with setAsync and you show me to use UpdateAsync and now it sems to work YES
Glad I could help!
My data saved in the output but not the leaderboard, any fixes please tell me?
best scripture ever, best Roblox studio tutorial ever
"scripter"
Aw, thanks a ton homie :D
why will i not sub and like when you helped me a lot to make a simulator game! I sub! i like! i Comment! pls do more series like this!!! Keep it up
hey montzer, i love your tutorials, just wondering for some reason when I leave my data will not save, I have tried everything and the script seems to be the same, i just cant figure out whats wrong?
hi i have a big problem! i did what you did but on 19:38 the food and coins are still not increasing.
did you uncomment the line below
my data didnt save when i did the same script (with different names)
there was no errors or anything it just didnt save?
ive got https requests and studio api service on aswell
it´s not working wen i stop i can see that die printet table is saved but wen i start again nofing saved.
When i stop the test thing it says it saved but when i press play it doesnt reload that data (I fixed it i accidently put a lowercase t for dataTable :|
How come when I test it on roblox studio the numbers save, but they keep going on and on your screen they dont, is it because I don’t have the giveplayercurrency(player) to comment
dude ur the besttt
Monster, when I did the data saving, instead of the leader board saying how much food I have it just says my name any ideas how to fix?
Thank you, you are helping me so much
I'm glad it helped :D
@@MonzterDEV in the auto clicker series in the 1st episode it doesnt work for me and i did all correct do you know why?
@@MonzterDEV nvm i rewatched the video
and now it works thank you so much now i know so much about scripting
That's insane that you know all of that and can code it without thinking twice
This was actually when I did it without thinking, most of my future episodes are scripted beforehand so I can produce a better episode haha!
do you know how to make the words grey while your scripting on pc?
@@SlappedYTT use "-- [message]"
@@SlappedYTT Ik im late, but if you highlight the text u wanna comment (make grey), and click "ctrl" and "/" at the same time
Then if u wanna undo it, highlight it and do the same thing
I’m stuck where is says
save(player)
(Idk what to put here)
If leftPlayers == 0 then
Pls could u help
for _, player in ipairs(allPlayers) do
coroutine.warp(function()
save(player)
leftPlayers -= 1
if leftPlayers == 0 then
finished:Fire()
end
end)()
end
finished.Event:Wait()
end
end
Hi! I tried to load my game after the shutdown part and instead of printing a table it shows the error message "cloud_319094400.Model.WeatherScript:35: attempt to call a nil value - client/server" , does anyone know how to fix this?
Great guide, so thanks a lot for that. Quick Question: When I looked into Roblox a couple years ago ppl said to use the AddIn DataStores2 as the built in one was not reliable. Is this fixed or may I run into troubles using the internal one?
So I have no experience DataStores2, but I have recently began using ProfileServices. I took a glance over DataStores2 and I believe it's a Module, which still uses the normal Roblox DataStores. If that's true, then whatever 'issue' DataStores2 fixes, you could implement that fix yourself.
If DataStores2 was using its own Database outside of Roblox's DataStores, then I'd say you might not be able to implement that fix to the Roblox DataStores yourself. Although, I could certainly be wrong because I haven't look too deep into this.
Recently I chose to use ProfileServices because I like the way it allows you to work with the Data. It feels more modular, organized, and easier to use. It also has additional 'features' / 'fixes' which I wasn't even looking for, but are nice added benefits.
I haven't published many games which gained large audiences, so it's hard for me to account for all the possible exploits or bugs that could come up, without having the actual experience. Although my first game I released, used the same DataStore usage I teach here, and while playing with other Players, I never saw a single data issue. Although, the amount of Players wasn't more than 100, so it's a small size took really find all possible issues with.
With all of that being said, I do think it can be beneficial to use a Library/Api/Module like DataStores2 or ProfileServices, but I also believe it's extremely helpful to start off and learn how to use the basic DataStore. The knowledge and better understanding should translate if you decide to use a Library instead!
Tip : Use profile service plugin for better data store
I completely agree and it’s something we did in the newer Simulator series!
I don't understand why it doesn't seem to me that there was an error but instead of it appearing to me that 10/50 was saved, it appears 0/50, any help?
as soon as i added this data storage thhe currency and leaderboard just fully stopped working
What if the problem only occurs on :GetAsync() but not :SetAsync()? Do you want the game to save when data could not load? (Probably no)
Does anyone know how to fix the problem where it comes up with “ServerScripSercice.playerdata:54: attempted to index nil with ‘UserID’” I don’t know what to do and I feel like no one will respond for weeks
We will!
@@MonzterDEV oh I gave up on this series I am now on the clicker one and it’s going much beyter
Hey monster! I know it's been a long time since this was uploaded but I'm finding it very useful. I have question. When you put local allPlayers = Players:GetPlayers() Roblox tells me "Unknown global 'players' " how do you fix that?
Make sure that your first line of code is local Players = game:GetService("Players")
And make sure you didn't spell anything wrong in your code!
Yeah do what bruh-tn3mq said
Hi, My coding for some reason although has followed all the steps and print the tables, does no load the data after entering the game again, do you know the reason? ty
it always say: ServerScriptService.PlayerData:30: attempt to perform arithmetic (sub) on nil and boolean any idea how to fix it
I doesn't let me do allow HTTP requests..can i still do it even though its not there
thank you it helped me so much !!!!!!
I’m glad :D
My coins save but the food doesn’t.. when I check the output it shows “Data Saved - Server” it doesn’t show a number how do I fix that
omg tysm and this is working 8 months after
Glad it worked!
For me when I join the game my counter for food and money isn’t going up even though there aren’t any mistakes because in my script nothing was underlined as spelt wrong or anything and the counter was working perfectly fine after I followed the first episode pls help
On line 40 and line 78 the Enun part is underlined in blue and it is appearing as an error and the code isnt working
the leaderstats thing stopped working after i uncommented the food and coins script stuff
When i was creating the shutdown function, it said to me that im attempting to to index nil with UserId, what should i do, could u help me
so im stuck on the onShutdown function. Ive ran through the script multiple times and I dont see any typos, everything works well, but my data doesnt actually save. Ill load in and it will print food and coins both as 0, but when I quit the game they stay as 0? please help
rewrite the line of code
Is there a way to save datastores without using leaderstats?
how would you make it so the player gets bigger as the score/food gets higher?
If I leave a game in he's say " Not Running script because past shutdown deadline" and don't save a game date pleas help fix it
I started following this tutorial because the new ones rebirth system didn't work for some reason so i hope this one works!
I'd recommend you rewatch the new series Rebirth episodes because they do work, but hope this one works for you as well!
at 11:30 you put a function with out old value wouldnt u need old valyue after function?
BEST TURTITIAL
Idk what i did but when I enter the game i just starts adding numbers and i it won stop when i save it
Im Having trouble saving the data ive followerd everything and i have every line of code line to line and the data is not saving
im having a lot of lags after using this code and I cant really test the game in the studio now, how do I fix that?
Hello, it is saved for me but when I play it again it starts again but it tells me that it is saved. How can i fix it?
after i did the player data and tested it on line 19 in the manager i have repeat wait(1) until player.leaderstats it says theres an error on that and when i test the player data the leader stats dont show when i test plz help me
Same problem here.
Same
Same
16.33 what is that first line after leftplayers bc i can't see it?
SAME BRO
how do i get the plugin at the bottom that shows if code is working or not
if your data is not saving make sure "givePlayerCurrency(player)" is below the end at the under the kick script
do you know how to make the words grey while your scripting on pc?
@@SlappedYTTyeah, add dashes until it turns grey like this -
@@SlappedYTT put thes lines - two before the text
It is but My data still isn't saving
I can’t figure out what you did on the first I copied what you did I triple checked it but pls tell me if you think you know what’s wrong
Hello, I want to ask you something. I did the same thing as you did and the scripts, but when I entered the game, the number of money and food does not increase or decrease. Why did it not work? Please reply.
i have the same problem but he is never going to reply
I do everything what is shown in the video but everytime im done it doesn't shows leaderstats and it doesn't work, please help!!!
Same here
the second i saw this vid only had 402 likes i immediately liked and subbed because these tutorials are sooooo good and helpful
do you know how to make the words grey while your scripting on pc?
@@SlappedYTTCtrl + /
19:11 just to remember where i stopped because data isnt saving when i rejoin in studio it just starts over from 0
This Man Deserves At Least 100k subs compared to what he is making
Thanks ☺️
do you know how to make the words grey while your scripting on pc?
@@SlappedYTTjust put the lines 2 times
the script ended up not working i rewrote it too and it just made things more frustrating idk what im doing wrong!
how do u see like the commands u get like data saved!
i dont see that on my file
Thanks 👍
No problem 👍
itts saving when i leave but when i load back in it dosent load why is this happening please help me
for some reason on the second user Id variable it says "ServerScriptService.PlayerData:53: attempt to index nil with 'UserId'" do you know why this happens?
Same thing happened with me, I just made sure that everything was exact and make sure your “players_“is lowercase
hello! I got an error saying "Info is not a valid member of Frame "Create"
20:00 he sounds so happy 😭
saving data doesnt working for me when i start game and get 5 coins and foods and when i turn it off and it says everything need to say like in a vid but when i make one word grey and after turn on it it says 0 again and idk why
same issues
hey when i tested at 14:40 everything worked but it didnt print nil
it says data saved and stuff and there is no errors but the nothing is in the table when its printed and data isnt saving or it isnt loading im not sure ive tried many different datastore scripts including this one
Same with me did you ever fix it?
same
My first "Player_"..userID is having issues, what do i do?
For some reason the game keeps the table values in the output correctly BUT neither the leader stats or the GUI display the saved data. Causing the data to then get changed to whatever data they got on THAT server
@MonzterDEV please help
yes bro, me too, do u know how to fix that now?
No
The if RunService:IsStudio() then command says that RunService is a unknown global can you help me? It’s not working
did you add "local RunService = game:GetService("RunService) as the third line? The line makes it a local variable
this guy needs to have a million subscribers
Aw, thanks!
Ofc Homie@@MonzterDEV
3rd episode is harder, but it is manageable@@MonzterDEV
I also want to know why my ipairs(toolConfig) is having a error and also my while true do
task.wait(30)
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(save)(player)
end)
@@MonzterDEV save funtions
I got an error telling me that my code can't index something that doesn't exist and it's in this area in PlayerData
local function save(player)
local userID = player.UserId
local key = "Player_"..userId
it should be "Player_"..userID
hi it say it saved my coins put then it does don't give to me back what should I do
Plus someone can help me , i did everythig right but when i try to leave and i rejoin , i only get the food but the coins is back to 0
it saved the data but didn't when i joined again the number go back to 0 but the data is still there
Also in game settings allow API Services to make data work
I need Help ive done the scripts right but the leaderstats arent showing up pls help me fix it
does it give you any errors?
Can someone help me , i load into the game but i dont see the leaderstats and i dont see the food and coins rising . Help
This was a good tutorial and all, I really like how you explain things, but when I leave it says data saved and then when i join back the table prints my data but the data doesn't go into the leaderstats im really confused because i followed step by step, Please Help!!
happend to me i still dont know what to do