Save Player Data with Roblox Datastores
Вставка
- Опубліковано 7 чер 2024
- DATASTORE EDITOR ► devforum.roblox.com/t/datasto...
MERCH ► shop.gnome.codes/
DISCORD ► / discord
TWITCH ► / gnomecode
TWITTER ► / gnomecoderblx
WEBSITE ► gnome.codes/
TIMESTAMPS ►
00:00 Intro
00:15 What is Datastore
01:27 Saving data
07:45 Loading data
12:26 Enabling API Services
14:00 Combining Leaderstats and Table data
15:43 Testing
16:16 Editing Datastores
16:58 Handling Server Shutdown
20:40 Outro
I was never good with how to use tables so this helped a ton, thank you.
I hope you had a wonderful Christmas with your family. Nice to see you still pushing out videos.
GnomeCode is awesome. He makes actually good videos and explains almost everything. Keep it up GnomeCode!
working on a new game and stuff like thisll really help. thanks, gnome!
I was gonna bash on the gnome but this is pretty well-engineered. Wish i had you when i was learning how to code on Lua.
Thank you sir, never seen before the repeat until implementation
thank you gnomecode for making awesome tutorials and inspiring tons of great games!
Can we all agree GnomeCode is the best roblox lua teacher on youtube!! 😊
Oh most definitely
yes it's an awesome thing.
Better than TheDevKing
yea the others are unhelpful
definetly last time i did a tutorial from TheDevKing it didnt even work
All the other videos I've watched show you how to do it but don't teach you so thank you gnomecode
great video as ever!
One small point. I would save the Player.UserId to a variable when saving or you wont be able to use it if the first attempt fails as the player object will be gone by then.
also, not too big a problem, but with normal datastores there is a limit of 1 read/write per 6 seconds to the same key
Excellent points, thanks griffo
@@GnomeCode your cool i like you
@@GnomeCode Can you make more doors?
Oh yeah for sure.. Everybody if you are reading this and feel a little lazy to do it, I promise its worth please follow his advice. It saved me.
This is my script if you are confused on how to do it : local function plrLeaving(plr)
if sessionData[plr.UserId] then
local success = nil
local errorMsg = nil
local attempt = 1
repeat
success, errorMsg = pcall(function()
local plrUserId = plr.UserId
database:SetAsync(plrUserId, sessionData[plr.UserId])
end)
attempt += 1
if not success then
warn(errorMsg)
task.wait(3)
end
until success or attempt == 5
if success then
print("Data saved for:",plr.Name)
else
warn("Unable to save for:",plr.Name)
end
end
end
@@onewill8905 Please help, I get an error message "DataStoreService: ValueNotAllowed: Dictionary is not allowed in data stores. API: SetAsync, Data Store: PlacementBoards" Just before that line I print sessionData[player.UserId] which prints { ["Placement"] = -1 } I understand that its a Dictionary but I followed the code to a T. cant find where I made the error as to my understanding sessionData[player.UserId] = playerData and playerData = {["Placement"] = -1,}
It didn't work and now it's 3am and I'm struggling on how the hell the leaderboard disappeared:,D
bruh
Great Video! I learnt a lot from this channel
i was about to add datastores and then i got the notification about a gnomecode video
Thank you so much for these tutorials! I honestly wouldn't know what to do with them.
Btw, How do I make the Animate2 script compatible with scripts that load other animations?
I love your content man
i learn a lot
i did have to get some help for more leaderstats but your a lifesaver i spent hours on trying before hand thanks
Bro can you help me?
Thanks gnome for always doing tutorials on things we all know other roblox how to creators can never do due to their laziness
on god
??
This was a great video to help make Datastores clear whilst waiting for Doors part 8. Also for Doors part 8 you should make the other place where everyone joins so you can go into a match with your friends and nobody else
He already did that with lobby elevator video
we even not added ambush, dark rooms and more... and you already want to take a step towards multiplayer?
@@GreatRamilYT it can already be multiplayer me and my pals have been playing through my version lol
@@GreatRamilYT plus we have all the bases we need to recreate the game
@@KoalaOnYT_ for now we have to finish some more banal things, but for now you can use the vip server or find a tutorial on how to make multiplayer
i made a datastore but one of the variables doesn't work, when it changes, it doesn't fire the "changed" function
yes the plugin edit video sounds great too :)
Great Video! Was Helpfull for me that dosent understand DataStores.
You are helping so much! Liked and followed you!
This is something i've been looking for for aaagggeeess. you explained it perfectly.
I have an idea for a tutorial. how about how to make a capture point system used in Domination gamemodes? i havent seen any videos on how to do that. i thought you would use Region3 but couldn't get much further as I am a beginner at coding.
this would help me out a ton. thanks for the great video
every tenth of a second while a player is within 10 studs of a capture point you could update capture progress by an amount and do other visual rigamaro
to get wether or not a player is a certain distance you do (CapturePoint.Position - Character.Position).magnitude
These are so clutch tysm
Out of the many UA-camrs that I've watched to learn Roblox scripting, you GnomeCode have taken 1st place. I appreciate you not skipping over or poorly explaining even the smallest of details that may be crucial for a beginner to understand. Thank you for the great video.
YES
I agree GnomeCode is #1
gnomecode you are da goat when i am a millionaire roblox-developer you can have 1 dollar
btw ur website is blocked for some reason :(
Question, in the beginning when setting the local variable for database “data” - how is this database created initially? Does simply setting a variable connecting to the service with a string name create it as well or just query/update it?
Best lua teacher!, A very calming voice too, Not a screechy 9 yr old, ty
I love all the games u make ! Teddy is my favourite!
This is gonna be useful in my next game since its a long game!
This will be helpful and also I bought some of your merch
Hi gnomecode! Just asking if you could maybe make a tutorial of how to make a stealth/action FPS game like Entry Point! Its a fun concept and idea! where you can either sneak around to clear your main objective(s) or go full loud with shootie shooties and take out infinite waves of enemies while you clear or complete you objectives(s) with also saving levels and characters maybe?
Hey GnomeCode, I was making a cart ride game, but classic carts like you see in cart ride into Rdite for example are a bit too boring for me... I've seen alot of games with very interesting carts like in "Cart ride around nothing" or "Cart Ride Delivery Service", can you make a tutorial about those and how to make them? thanks!
currently, i could never write this, but i can actually understand it. you explain very well. is this all there is to a datastore? still puzzling over how profileservice seems like an infinitely complex version of this
I remember four years ago I was watching your scripting tuts. Now when I look at your profile you have nearly half a bil visits man. Ur the goat
I would suggest for conveniency if you wanna experiment first start off with the loading function and print out what you get because if something is wrong and it saves the wrong thing its a real pain to revert it every time.
nice! at the first half its completely fine and fully working. but at the combining leaderstats it got messed up and idk the problem even though i checked it like 5 times and i still could find the problem to fix why it cant save my data. pretty nice!
Yessir i needed this
Thank you, this really good working
what a coincidence, I was just looking for videos about datastore
Thanks for the awesome tutorila!
so helpful!
hey gnome code! i have a question. I saw your Custom Charecters Video and i was thinking if you could make the custom character apply only to one team. Thanks!
Is there a way to use this to save the players clothing when they leave the game? Such as if they customised their character while in the game and then upon leaving it saved their clothes and accessories and all that, then when they rejoined it loaded all their clothes back on?
Bro, u are the best teacher! I like to watching u. Sorry for my English 😅
great video
Bro this is insane
amazing tutorial !
are you going to continue your doors series? if so, can it be about the guiding light death messages? y'know the blue texts that tell you who you died to and how to survive it next time
Cool video but why you don’t upload about teddy anymore?
Could you continue the Tower Defense Series for some additional towers (example: farms, commander, dj, vehicle support tower, barracks like in tower battles). If you do, then do it when you have time to do that. That's all.
create it urself. he cant help u with everything
how do i edit it from other scripts? like add stuff to datastore (like dollars + 20) from another script?
Hey GnomeCode, Love Your Content And Tutorials, i Was Wondering Could You Make A "How To Make A Game Like Roblox town" Series? I Would Love To Watch, Cheers!
Soooo the tower range is broken. When you click on and off and sell it doesnt go away? Any fix?
Could you please consider doing a video on Ordered Data Stores?
such a helpful tutorial
gnomeode, great vid, but i'm using the datastore for a clicker simulator but the clicks aren't saving it's adding them to the leaderboard but when i go back in the clicks are back at what they were, there's no errors or warnings please help
great video
butt I have a problem with it
Im trying to fire a remote event when player buyes something and finding stuff that player bought in session data table and giving it +1
I tried table.find output nil
print(table.find(SessionData[plr.UserId], eventInvWho)) -- this is the code I tried
I tried couple things too like adding new data when player buys it didnt work
can anyone help me with it
Hi, so in my games you unlock 5 different Billboard guis called “accolades” and I was wondering how I’d tweak this script to save those unlocked guis.
Could you help with the footstep video? Nothing works when I do it all, not even the walking animation you made
That's great and all but how do you store a list of values that I can table.Insert() more values into?
Gnome code how much robux do you think you should pay for a build? Assuming that it's a mid poly build and it's a small build
you earned ez subscribe, bro
hey gnomecode, could you please make a video about remote functions (you made on remote events only), i don't think you made one and I think it might help many people
Well basically the only difference is with remote functions you can send information back to whatever is sending the function, so the client can send something to the server and the server can send something back based on the information the client sends. With remote events the sender can send information, but it can't receive information back.
why does the console say:
Argument 1 missing or nil
also does this work for other data too like weapons,location etc
How do i save items from the datastore. Like i bought something in game and want to save it in my inventory . Please help
How would I add more values, though?
yo bro but lets say like for example if i have a string value, if its changed in game like the actual value how do i save it? is tht possible
Can someone explain why i save data in number format but my places sees this data as nil?
(I want make shop but i have a lot of places)
OH IT WORKED TYSM
i dont know if i should feel insulted or honored when he calls me a gnome..
Hello I need help. Can you do a video where you need a certain amount of coins to change phases? For a example...
I touch a part and if you have 200 coins then reset or die then you change phases with new attacks?
just check the player coins when they touch the part
a good lesson, but it would be nice to look at old materials
Hello GnomeCode! I’ve been someone who’s been watching your tutorials for a long time, and they’ve really helped me out! I’ve just been wondering, I think it would be pretty cool if you could show us how to make an rpg kind of game. It could get some views….
The changed event seems to not fire when the dollars is changed. Why is that?
Can u make a tutorial on RunService bc I get confused all the time
Can you make a tutorial on the death screen and boss defeat screen? Like how when you die in dark souls you get YOU DIE or like if you defeat a boss you get VICTORY ACHIEVED or something and is it possible to change the text like for example like instead of you died its Your mom or you can change it to Death Achieved?
for your next video could you modify and make droplets rpg kit more advanced? (for the kit just search up droplets modified rpg kit)
Thanks! How can I save data in multiple places within the game?
So.. Can i buy some data in data[Stores]?
GnomeCode i have something to ask you, can you make a game like steep steps, i really wanted a tutorial series for it..
I need some help. It doesn't work for me. Nothing comes up when I leave. My best guess is that it'd not finding my player ID in the list and therefore not running the leaving function. But why it doesn't find it is what I'm trying to work out. It's been copied word for word
Happens to me too. RIP :)
thank you bro
what about saving with item like multiple type of guns/weapons how to apply to it?
New series! "How to make a game like entry point" rn.
im trying to make a game where jump power and walking speed increased by 10 and 1 ever 5 and 1 seconds, and when i tried this tutorial, the data didnt save can anybody help me pls
do you know if you can make a murderer mystery type of game?
It isn't working for me. It says that value of type nil cannot be converted into a number. It happens on line 46, when I'm putting the Dollars.Value equal to the sessionData[player.UserId].Dollars. Anyone can help me?
can you make a tutorial on a button masher with a camera for a keyboard key and if you win you live but if you fail you die kind of like the end of the doors seek chase kind of like that Doors X Fortnite (Collision Button Mash) if you can thank you!
Can you make a video on how to edit datastore manually?
Can you do a tutorial on how to make a game like the mimic? You may have heard of it but if you can much appreciated!
Could you make a vid on how you make the mape choice like in tower heroes. That you have to make a server to choose a map
hey Gnome, I don’t know if you read this, but I’ll still say if you know how to make games like kaijuparadise or transfurinfection, I would really like to see some kind of tutorial because they don’t exist at all, and if there are, then there are scripts that did a very long time ago
I've noticed the brightness in recent videos has been quite low- anyone know why?
You should make a tutorial on how to add collectable gold into the Doors Tutorial series, I'd love to see it!
Can you make a series of how to make a steep steps game..
I recommend checking out DataStore2, as it is one of the best data store modules out there, many popular games uses it as it is really good at preventing dataloss and other bad things!
Hey GnomeCode did you stop the Doors Tutorials Series?🤔
I am waiting for the next part...
gnomecode how do you make your horror monster work i watched the tutorial and its animating wont work
For some reason, the function for playerremoving runs for me and if sessiondata = true, but the repeat loop will not run, aswell as the pcall.
same for me have you found the solution?