DataStore (Saving & Loading Player Data) - Roblox Scripting Tutorial

  Рет қаралды 23,590

Suphi Kaner

Suphi Kaner

Күн бұрын

Discord: / discord
Patreon: / suphi
Donate: www.roblox.com/games/7532473490
Datastores: create.roblox.com/docs/script...
BindToClose: create.roblox.com/docs/refere...
0:00:00 - Intro
0:01:47 - Create Project
0:04:08 - DataStore Script
0:22:55 - Editing Player Data
0:39:02 - Outro

Пікірлер: 146
@5uphi
@5uphi Жыл бұрын
On line 31 I made a mistake instead of folder:Destroy() it should be player[folder.Name]:Destroy()
@Raykiv
@Raykiv Жыл бұрын
@@SurgeDev1094 Because thats an Instance not a String therefore it can't parse Instance as String
@mathless_
@mathless_ 3 ай бұрын
i actually get an error from changing it to [folder.Name] "attempted to index nil with 'Destroy'"
@NotRubik
@NotRubik Жыл бұрын
I love how easy it is to track your train of thought as you work through the code. Also- unlike in most datastore tutorials by other people- your code accounts for players leaving right before data is changed, servers shutting down, etc. Incredible work!
@brokemono
@brokemono Жыл бұрын
Also writes quite efficient and clean code compared to others. That game:BindToClose(function() was especially good. Not even chatgpt recommended it to me when I asked if there were any safety measures I could add, only when I mentioned it. Before mentioning it chatgpt said to always have a backup plan but also that I can rest assured that DSS and DS2 will take care of it...haha, I doubt it but anyway.
@daniilka353
@daniilka353 Жыл бұрын
This man made a whole game in 1 video and taught me how to datastore multiple items. You are a legend
@gdetonator1182
@gdetonator1182 2 жыл бұрын
Very helpful tutorial for my future projects! Thanks for providing tutorials of this quality. Keep up the good work. I'm sure you will become the go to for roblox scripting tutorials!
@MrDonut360
@MrDonut360 Жыл бұрын
i always learn more then what i came looking for from your videos
@aurora9183
@aurora9183 6 ай бұрын
This is so informative and one of the best tutorials ive come across. TYSM
@user-om4fe9yx1c
@user-om4fe9yx1c Жыл бұрын
You are the best, keep up with the good work!
@superstorm4228
@superstorm4228 Жыл бұрын
Awesome video, just like other comments below I love how you go back and explain your reasoning for all of your decisions which really helped me follow along as it wasn't just do this and that, but giving my the why's.
@5uphi
@5uphi Жыл бұрын
:)
@Fimutsu
@Fimutsu Жыл бұрын
i don't usually comment but i had to say The most perfectly made datastore tutorial in existence
@MrAgain12
@MrAgain12 5 ай бұрын
Thank you. I have this script working in my game, as of today. It wasn't easy to get it to work ( I had a couple of syntax errors that prevented the script from running), but I eventually persevered after trying numerous times to fix my mistakes in the script.
@clappingtoday7167
@clappingtoday7167 Жыл бұрын
very helpful! my friend and i decided to make a game together but i never actually made any games that require saving
@KebeMaro
@KebeMaro 2 жыл бұрын
This is amazing!
@d.veloper826
@d.veloper826 Жыл бұрын
Your tutorials never disappoint! Simply incredible. How do you know so much?
@brandonwayne1998
@brandonwayne1998 6 ай бұрын
This is so underrated oh my thank you!!!!
@cdcbeats551
@cdcbeats551 10 ай бұрын
I know this video is a year old but I just want to thank you for fixing the biggest issue in my game! I couldn’t figure out for the life of my how to just change a text label to show the amount of items and now it’s all figured out! Thank you so much I subbed just because of this video
@MrWhiite
@MrWhiite 11 ай бұрын
Probably the best data store tutorial
@Yuusaku-Marlowe
@Yuusaku-Marlowe Жыл бұрын
You deserve more subcribers and views =( Your talent must be know
@PrestigePotato
@PrestigePotato 2 жыл бұрын
I have spent torturing hours trying to learn datastores because every tutorial is copypasting leaderstats without explanation of how anything works. Thank you!
@absolute_zero982
@absolute_zero982 2 жыл бұрын
This video help more then the article thank you
@durpable1417
@durpable1417 Жыл бұрын
very helpful for my game! your underrated
@5uphi
@5uphi Жыл бұрын
Thank you
@ignayep
@ignayep 9 ай бұрын
Good Video!, Thanks for this!, espero estes bien! :D
@moa7635
@moa7635 Жыл бұрын
I did not knew that you are the owner of "RO-DRONE"! I played your game by hours and hours when I was a kid! You marked my infancy! I'm so greatfull of you doing such a good game! ❤
@user-ep1gz3fk1l
@user-ep1gz3fk1l 9 ай бұрын
wow, I didn't knew about you can call table:method(...) as table.method(table,...) TYSM
@charliewagenbrenner5994
@charliewagenbrenner5994 Жыл бұрын
You and gnomecode are literally the unspoken gods of Roblox
@Nosila_T
@Nosila_T Жыл бұрын
thanks for share your knowledge!
@user-xc2hy1ur2h
@user-xc2hy1ur2h 2 жыл бұрын
Лайк не глядя.
@dXOHOXb
@dXOHOXb Жыл бұрын
Suphi already addressed the mistake of destroying the folder on line 31 on mark 20:58 of the video and yes this removes the very folders for recording any player within joining thus when a player leaves the server, the main server folders are removed, not the specific player's folders hence he said it's 'player[folder.Name]:Destroy()' meaning to refer the player's folders, Not the main server's folders 'folders:Destroy()'
@5uphi
@5uphi Жыл бұрын
Yup I beat my self up over this all the time in the future I'll redo the video and delete this one
@CheeseY420
@CheeseY420 Жыл бұрын
Thank you SO MUCH!
@5uphi
@5uphi Жыл бұрын
Your very welcome
@imthebestmayne122
@imthebestmayne122 Жыл бұрын
I know this is a lot to ask, but could you possibly make a video on saving Serialized data, i.e. models (or just serialization in general) with data stores? I didn't see anything about requests on your Pateron, so I figured I would post a comment. Thanks for a great video.
@5uphi
@5uphi Жыл бұрын
You can leave requests in the discord channel
@ShadowClaw_Dev
@ShadowClaw_Dev 2 жыл бұрын
I already know datastores but I am still learning again if I am doing something wrong lol. Well, nice to see they finally rewrite the DataStoreService into Roblox Creator Documentation.
@DavidWinstead
@DavidWinstead 9 ай бұрын
Awesome tutorial as always, just what I needed! If you can remember since it's been over one year since you uploaded this tutorial...How do I use this method to have a collectable item that when one player collects it, it also remains in the same spot for all other players to collect as well? I've been trying to figure this out for a very long time now and no one that I could find was able show me how to do just that! Please Help!!
@5uphi
@5uphi 9 ай бұрын
You save a bool value false if the player has not collected and true if they have collected it then in a local script if it's false place the item on the floor
@DavidWinstead
@DavidWinstead 9 ай бұрын
@5uphi Thanks, I've created the whole example, and it works great, I even added bananas to test what I've learned from this tutorial. I'll try what you suggested tonight.
@matzfamous370
@matzfamous370 Жыл бұрын
I have a question, i made a store where you can buy characters (models) but im wondering how you would save that, my idea is using a model script, and assigning each character their own 'code', im wondering if that would work or should I use a different system. Basically im asking, if player buys, how do i add value to datastore and save it
@topryuno
@topryuno Жыл бұрын
the saving data isnt working for me. i keep trying to go back into the video over and over again to see if i missed something but its just not working. i dont know if this is only for leaderstats or if i missed something but i can edit the players data and load it vorrectly but it doesnt save the new value that ive edited.
@araphis836
@araphis836 9 ай бұрын
can you try waiting till the player loads when the playeradded function calls instead of kicking the player so that the function has to wait for the player to load before running any code
@praneshbalaji8047
@praneshbalaji8047 2 жыл бұрын
can you make video about how to make fortnite build system in roblox studio also with wood cutting farming materials to buld kind of
@aeaeaeae9351
@aeaeaeae9351 Жыл бұрын
Hello Suphi! Could you please check if I correctly understand the trading exploit? So basically, after the player leaves, their Player instance is still in the DataModel, so the DataStoreService can save their data from the folders found in that Player instance. But after saving the data, right before it gets removed (the Player instance), the RemoteEvent for trading gets called and it takes the value from the said Player instance’s folders, and it gives that value to the other player, and the first player’s Player instance is removed from the DataModel afterwards. So technically there is no duplication HOWEVER since the data got saved in the previous state (before the trade), the player that left the game, can rejoin and can overwrite the data that got changed in a trade, resulting in a successful duplication. I’m terrible at explaining, so if you didn’t understand something, I’ll try to re-write it, just lemme know. Thanks
@5uphi
@5uphi Жыл бұрын
Correct so after you save the data it's important that you don't use it anymore
@xKaihatsu
@xKaihatsu 2 жыл бұрын
At 19:30 I don't really get why you are yielding in BindToClose because the servers are going to shutdown in 30 seconds regardless of whether or not every PlayerRemoving event has completed. So wouldn't it be better if you had a save function and looped through an array of players making sure you're saving their data instead of doing nothing?
@5uphi
@5uphi 2 жыл бұрын
When the server starts to shuts down all players are kicked from the game so the PlayerRemoving event should fire almost instantly after the server starts to shutdown so the BindToClose yield will only wait until all players datastores have been saved then as soon as everyone's datastore has been saved it will stop yielding so the server will not just be standing there doing nothing during the 30 seconds it will be saving everyone's datastore
@Vursosa
@Vursosa Жыл бұрын
Can you explain (If you know) how data store v2 works? (Not datastore2) it would be really helpful to me and a lot of other people since there are no vids at all talking about roblox's datastore v2 that comes with Versioning and other features. I understand how data stores work for the most part but I'm not sure how the versioning works as it's kind of unclear on the website what makes it different from the regular datastore and how you use it and apply it to your current data store or does it just automatically apply and you just have just do something to access it. (The devforum post is "Datastore v2.0 - Now Officially Launched") Thank you.
@5uphi
@5uphi Жыл бұрын
When you use the datastore your essentially using Roblox's datastore v2 every time you set or update a value into the datastore Roblox will save it to a new version and the old version is kept for 30 days there are some methods you can use to view and revert to a older version if you wish so there is nothing you need to add to your code versioning will automatically apply to your project
@Vursosa
@Vursosa Жыл бұрын
@@5uphi Thank you so much that just made everything more clear on datastore v2
@akzholtosamaeva117
@akzholtosamaeva117 2 жыл бұрын
♥️♥️♥️😍😍
@animeSlayeri
@animeSlayeri Жыл бұрын
this was quite confusing to me but I still wrote it and understood some stuff! I am kind of struggling to understand what those things in brackets really mean. [these ones]. I know they are keys but I don't understand how are they really used.. Could you explain them ? Great tutorial btw ^^!
@5uphi
@5uphi Жыл бұрын
I talk about tables in my snake game video maybe try watching the first half of the snake game video you can also message me in my discord channel and I'll try to help you there
@animeSlayeri
@animeSlayeri Жыл бұрын
@@5uphi perfect thanks!
@ScriptingCase-
@ScriptingCase- Жыл бұрын
Hey, this didnt work for me. I followed everything closely and precise but it still doesnt work. could you give me a copy of the text?
@IlIlIllllllI
@IlIlIllllllI 3 ай бұрын
hey, i truly would like to thank you for this video, although i do have 1 problem, i always get the "Not running script because past shutdown deadline" warning after disconnecting, my data gets saved and everything works as expected though. Is this a false alarm? an error in the script? do inform me if you could. thanks!!!
@5uphi
@5uphi 3 ай бұрын
Something is wrong with your bind to close
@Theveryday
@Theveryday 11 ай бұрын
hey is there anyway to like get an specific value inside the tables with ordered data stores? Been trying for a while and I cant figure it out
@5uphi
@5uphi 11 ай бұрын
use getasync
@Theveryday
@Theveryday 11 ай бұрын
@@5uphi yeah but what if I wanted to make a global leaderboard? Getting ordered data store wont let me get the values inside. But anyways ty ill try get async
@lennyprogrammer
@lennyprogrammer Жыл бұрын
One recommendation, instead of immediately kicking the player if the data fails to load, try loading it at least 5 times, and then kick if each time was an error.
@5uphi
@5uphi Жыл бұрын
Another option is to not kick them at all but don't let them interact with anything that uses the DataStore
@flairewithane
@flairewithane Жыл бұрын
Love the tutorial and appreciate it. However, after copying exactly what you have done I noticed that the values always reset back to the default. For example: Starter money in my game is 3K…I played it a bit and lowered myself to 2K. In the output, it says it saved the values correctly but in reality all is the values reset back to what they are in server storage. Any tips/ideas?
@flairewithane
@flairewithane Жыл бұрын
Ah never mind. This was my fault…😂
@GxdCxmplexes
@GxdCxmplexes Жыл бұрын
@@flairewithane hi. what was wrong? i have the same problem
@flairewithane
@flairewithane Жыл бұрын
@@GxdCxmplexes oh goodness that was months ago. It was either an error on my end(like a typo in the code) or I had lowered the amount of my money in the client side instead of the server side.
@GxdCxmplexes
@GxdCxmplexes Жыл бұрын
nvm i found. Thanks anyway
@bruh-zy9ed
@bruh-zy9ed Жыл бұрын
How would you expand the system for it to be able to additionally save the tools a player has?
@5uphi
@5uphi Жыл бұрын
you need to add the tools to the data table this can be done by adding them to the table directly or by adding values to a folder dynamically
@liam2795
@liam2795 Жыл бұрын
New channel
@liam2795
@liam2795 Жыл бұрын
*nice
@luxyixd6877
@luxyixd6877 Жыл бұрын
hi, how to implement the data to leaderboard rank? I try using GetOrderedDataStore doesnt work,return empty tabble, but I can see the data if using key or userid
@5uphi
@5uphi Жыл бұрын
This video won't help in any way on how to use a ordered datastore
@rite0824
@rite0824 Жыл бұрын
Is there any way to make it so a value (let's say from serverstorage) clones to the player data folder, and when you rejoin it stays in your inventory?
@5uphi
@5uphi Жыл бұрын
Yes it is possible when the player enters the game again you loop through there data and add any missing values
@rite0824
@rite0824 Жыл бұрын
@@5uphi alright
@ryjk8865
@ryjk8865 Жыл бұрын
have a question when PlayerAdded, we loaded DataStore onto clone and parented in player.playerData. then whenever giving apple point, giving it to player.playerData. When Saving, getting the value from ServerStorage.Playerdata would it save the data that is stored inside playerFolder? Thanks for the great videos
@ryjk8865
@ryjk8865 Жыл бұрын
and is it safe to use intValue in workspace and replicatedStorage? It seems like client cannot change the value but just bit curious.
@5uphi
@5uphi Жыл бұрын
It uses the server storage so it know the names of the folders it needs to save as there are other instances inside the player
@5uphi
@5uphi Жыл бұрын
It is safe check out this video kzbin.info/www/bejne/hJiUpoyme8ijhaM
@ryjk8865
@ryjk8865 Жыл бұрын
@@5uphi thank you for the such a fast reply.
@ryjk8865
@ryjk8865 Жыл бұрын
@@5uphi thanks again.
@turbohobo1116
@turbohobo1116 Жыл бұрын
Can you please make a video on How to store player data in a module script?
@5uphi
@5uphi Жыл бұрын
That is on my to-do list
@pepperdayjackpac4521
@pepperdayjackpac4521 2 жыл бұрын
This is also a tutorial for the basics of a collector simulator lol
@__unlimited
@__unlimited 2 жыл бұрын
It's not properly saving the data. After I printed "Saved: data", I tried adding a line to print(success) and it returns false. From here, I tried removing the pcall so it will print the actual error. It prints "Not running script because past shutdown deadline (x1287) " and "104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters." Can you help?
@5uphi
@5uphi 2 жыл бұрын
this was a feature added to studio some time ago devforum.roblox.com/t/898436 maybe you might need to enable it inside beta features
@__unlimited
@__unlimited 2 жыл бұрын
@@5uphithank you, i got that working. can you reply to the edit i made to the comment
@5uphi
@5uphi 2 жыл бұрын
if you message me in discord ill try my best to help you
@__unlimited
@__unlimited 2 жыл бұрын
@@5uphi its ok, i found the problem. it was that i was trying to save a color3value. i didnt realize in the video you said it can only save certain values
@5uphi
@5uphi 2 жыл бұрын
yes if you want to save color3values you will need to save each R G B values separately
@bl4ze0j
@bl4ze0j 13 күн бұрын
its saving but not loading why???
@huk7797
@huk7797 2 жыл бұрын
What is pairs and ipairs for when it can just be replaced with the table?
@5uphi
@5uphi 2 жыл бұрын
When you don't use pairs or ipairs lua will default to using pairs so the loops in this video are the same as using pairs
@GalaxinTM
@GalaxinTM Жыл бұрын
@@5uphi Pretty sure that’s a feature in Luau
@5uphi
@5uphi Жыл бұрын
I believe your correct as I don't use pure lua I'm not sure anymore what are lua features or luau feature
@Yuusaku-Marlowe
@Yuusaku-Marlowe Жыл бұрын
Can I ask about line 31 21:10 what happen if I don't destroy the folder ?
@5uphi
@5uphi Жыл бұрын
I made a mistake there it should be player[folder.Name]:Destroy() when you call SetAsync that call has a small delay so its possible that within that delay someone could trade items or something of that nature to another player and then the datastore would save with the item still in the original player so that would allow them to duplicate items so to prevent this exploit we destroy the folder preventing other scripts from working while the player is exiting the game so that it wont be possible to trade items or drop items on the floor
@Yuusaku-Marlowe
@Yuusaku-Marlowe Жыл бұрын
@@5uphi Thank you so much :>
@hermansmyth916
@hermansmyth916 Жыл бұрын
but its not local so everyone in the server can pick the stuff up. I want like a simulator where everyone gets an individual spawner of parts that they can pick up. but everyone can pick up each others parts and it looks weird. i suppose i need to use module scripts then and then require a local script and stuff.
@5uphi
@5uphi Жыл бұрын
This video's main goal was to teach you how to save and load player data but its down to you to design how the game works
@hermansmyth916
@hermansmyth916 Жыл бұрын
@@5uphi yes.
@hermansmyth916
@hermansmyth916 Жыл бұрын
@@5uphi thx for teaching
@dacianfd8418
@dacianfd8418 Жыл бұрын
How can i print the usernames from the database ?
@5uphi
@5uphi Жыл бұрын
Player.Name or Player.DisplayName or Players:GetPlayerByUserId() or Players:GetNameFromUserIdAsync()
@MaxKool5
@MaxKool5 Жыл бұрын
can you do this with a global datastore or is it only a normal one
@5uphi
@5uphi Жыл бұрын
There are only 2 types of datastore objects, GlobalDataStore and OrderedDataStore. This video is using GlobalDataStore
@MaxKool5
@MaxKool5 Жыл бұрын
@@5uphi oh i thought that global datastorse are for universes
@d.veloper826
@d.veloper826 Жыл бұрын
Please why do you use server storage instead of replicated storage?
@5uphi
@5uphi Жыл бұрын
So the original defaults are in server storage then they are cloned into the player where they get replicated there is no reason why you could not use replicated storage but it would be a waste of data sending the defaults to all clients if there not going to use it so if you want to reduce data usage it would be better for them to be in server storage
@d.veloper826
@d.veloper826 Жыл бұрын
@@5uphi Makes sense! Thanks for taking the time to explain. Merry Christmas and happy holidays.
@360sauce7
@360sauce7 Жыл бұрын
Will this save tools when a player dies?
@5uphi
@5uphi Жыл бұрын
No but it can be expanded to save tools
@360sauce7
@360sauce7 Жыл бұрын
@@5uphi Alright thx
@devdeepy5665
@devdeepy5665 2 жыл бұрын
Good to know! but your method is almost same as mine to save player tycoon data 99% success.
@5uphi
@5uphi 2 жыл бұрын
this is my simple method i have a more complex method that ill show in future videos :)
@superkc2557
@superkc2557 Жыл бұрын
@@5uphi looking forward to seeing this!
@whitewolf8763
@whitewolf8763 Жыл бұрын
@@5uphi Hello when the more complex method will come im waiting for it and also is this datastore script safe like will it there no memory loss ? Nice vid btw.
@5uphi
@5uphi Жыл бұрын
@@whitewolf8763 I have no date to when the complex method will come out and to the question is it safe its just as safe as every other datastore method at the end of the day the data is stored at roblox and if roblox one day decides to delete all the data then all the data will be lost there is nothing we can do about that other then saving the data somewhere else
@Moonjapp
@Moonjapp Жыл бұрын
Hello, is there any chance of getting data loss using this method?
@5uphi
@5uphi Жыл бұрын
if Roblox servers go down then yes
@Moonjapp
@Moonjapp Жыл бұрын
@@5uphi Any way to prevent this? Should I make a While true do loop and save the data like every 200 sec, to minimal the lose. Do you think that would help?
@5uphi
@5uphi Жыл бұрын
Yes you can save the data every so often to minimise the lose
@Tamla1959
@Tamla1959 10 ай бұрын
@@Moonjapp or you could use DataStore2, no need to add BindToClose or PlayerRemoved, it does it Automaticlly.
@Tamla1959
@Tamla1959 10 ай бұрын
why is data not saving in game but it is in studio, it dosent make sense.
@5uphi
@5uphi 10 ай бұрын
Maybe you forgot to publish?
@Tamla1959
@Tamla1959 10 ай бұрын
@@5uphino, i did publish, but its just not saving in game, only in studio, i really need this fixed, do you have any clue, because im lost.
@5uphi
@5uphi 10 ай бұрын
did you read the pinned comment on this video as there was a mistake
@Tamla1959
@Tamla1959 10 ай бұрын
@@5uphiyeah i did, but it still dosent save for some reason.
@5uphi
@5uphi 10 ай бұрын
then all i can think of is something it messed up with the script recheck the video and make sure everything is correct
@YoutuberIsUploading
@YoutuberIsUploading Жыл бұрын
this dude types like lighting mcqueen bro
@5uphi
@5uphi Жыл бұрын
AutoHotKey
@YoutuberIsUploading
@YoutuberIsUploading Жыл бұрын
@@5uphi how do you use it like that?
@5uphi
@5uphi Жыл бұрын
ill make a video soon about AutoHotKey
@YoutuberIsUploading
@YoutuberIsUploading Жыл бұрын
@@5uphi ah thanks
@princemontana7750
@princemontana7750 Жыл бұрын
bro my apples do not spawn
@5uphi
@5uphi Жыл бұрын
You must of missed something
@princemontana7750
@princemontana7750 Жыл бұрын
@@5uphi Yep, my bad, thank you
@roboket3524
@roboket3524 Ай бұрын
information overload bruh i aint that good yet to know half of whats going on. just some constructive critisism for you
@malcolm3779
@malcolm3779 Жыл бұрын
░p░r░o░m░o░s░m░ 😴
Suphi's DataStore Module Basics - Roblox Scripting Tutorial
1:18:59
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 47 МЛН
OMG🤪 #tiktok #shorts #potapova_blog
00:50
Potapova_blog
Рет қаралды 17 МЛН
터키아이스크림🇹🇷🍦Turkish ice cream #funny #shorts
00:26
Byungari 병아리언니
Рет қаралды 25 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
Save Player Data with Roblox Datastores
21:29
GnomeCode
Рет қаралды 93 М.
Making FNAF In Roblox
12:12
JimboRibz
Рет қаралды 633 М.
Datastore: A Scripter's Worst Nightmare Explained
9:55
Ludius
Рет қаралды 10 М.
Use Profile Service as Your Data Store! Roblox Development
28:13
I Made a Roblox Game in 100 Hours...
11:26
reyn
Рет қаралды 279 М.
Roblox Infinite Scripter Plugin
2:10:41
Suphi Kaner
Рет қаралды 92 М.
Cars With Suspension - Roblox Scripting Tutorial
1:13:22
Suphi Kaner
Рет қаралды 70 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 47 МЛН