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

КОМЕНТАРІ • 591

  • @Kaizentry
    @Kaizentry Рік тому +10

    I was never good with how to use tables so this helped a ton, thank you.

  • @GigaGnome
    @GigaGnome Рік тому +12

    I hope you had a wonderful Christmas with your family. Nice to see you still pushing out videos.

  • @keeguri
    @keeguri Рік тому +10

    GnomeCode is awesome. He makes actually good videos and explains almost everything. Keep it up GnomeCode!

  • @RichRBLX
    @RichRBLX Рік тому

    working on a new game and stuff like thisll really help. thanks, gnome!

  • @YuinAstrophel
    @YuinAstrophel Рік тому +4

    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.

  • @lolofuk87
    @lolofuk87 Рік тому

    Thank you sir, never seen before the repeat until implementation

  • @waffle_doge5594
    @waffle_doge5594 Рік тому +4

    thank you gnomecode for making awesome tutorials and inspiring tons of great games!

  • @huttle
    @huttle Рік тому +165

    Can we all agree GnomeCode is the best roblox lua teacher on youtube!! 😊

    • @ummmyah
      @ummmyah Рік тому +2

      Oh most definitely

    • @Giuyo
      @Giuyo Рік тому +2

      yes it's an awesome thing.

    • @BasedOnBrian
      @BasedOnBrian Рік тому +8

      Better than TheDevKing

    • @TheOfficialPWP
      @TheOfficialPWP Рік тому +4

      yea the others are unhelpful

    • @wolf9903
      @wolf9903 Рік тому +1

      definetly last time i did a tutorial from TheDevKing it didnt even work

  • @2_toastedbagels
    @2_toastedbagels Рік тому +1

    All the other videos I've watched show you how to do it but don't teach you so thank you gnomecode

  • @mr_griffolukegriffiths9166
    @mr_griffolukegriffiths9166 Рік тому +30

    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

    • @GnomeCode
      @GnomeCode  Рік тому +19

      Excellent points, thanks griffo

    • @GalaxyedRainbow
      @GalaxyedRainbow Рік тому +5

      @@GnomeCode your cool i like you

    • @CatgamerX
      @CatgamerX Рік тому +2

      @@GnomeCode Can you make more doors?

    • @onewill8905
      @onewill8905 8 місяців тому +5

      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

    • @Prillanator
      @Prillanator 7 місяців тому

      @@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,}

  • @azura_alien
    @azura_alien Рік тому +4

    It didn't work and now it's 3am and I'm struggling on how the hell the leaderboard disappeared:,D

  • @dunialajla
    @dunialajla 4 місяці тому +1

    Great Video! I learnt a lot from this channel

  • @DaAccountName
    @DaAccountName Рік тому +4

    i was about to add datastores and then i got the notification about a gnomecode video

  • @alejandrorivera9694
    @alejandrorivera9694 Рік тому +2

    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?

  • @alex965t9
    @alex965t9 Рік тому +1

    I love your content man
    i learn a lot

  • @giraffeplays7065
    @giraffeplays7065 10 місяців тому +2

    i did have to get some help for more leaderstats but your a lifesaver i spent hours on trying before hand thanks

  • @Ironbaby08
    @Ironbaby08 Рік тому +4

    Thanks gnome for always doing tutorials on things we all know other roblox how to creators can never do due to their laziness

  • @bisoncool1215
    @bisoncool1215 Рік тому +32

    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

    • @avgVar
      @avgVar Рік тому +2

      He already did that with lobby elevator video

    • @GreatRamilYT
      @GreatRamilYT Рік тому

      we even not added ambush, dark rooms and more... and you already want to take a step towards multiplayer?

    • @KoalaOnYT_
      @KoalaOnYT_ Рік тому

      @@GreatRamilYT it can already be multiplayer me and my pals have been playing through my version lol

    • @KoalaOnYT_
      @KoalaOnYT_ Рік тому

      @@GreatRamilYT plus we have all the bases we need to recreate the game

    • @GreatRamilYT
      @GreatRamilYT Рік тому

      @@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

  • @Afarmcow
    @Afarmcow 8 місяців тому +4

    i made a datastore but one of the variables doesn't work, when it changes, it doesn't fire the "changed" function

  • @7a8a13a5
    @7a8a13a5 Рік тому

    yes the plugin edit video sounds great too :)

  • @AlanShogs56
    @AlanShogs56 4 місяці тому

    Great Video! Was Helpfull for me that dosent understand DataStores.

  • @maaloyy_
    @maaloyy_ 10 місяців тому

    You are helping so much! Liked and followed you!

  • @epicfriez
    @epicfriez Рік тому +2

    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

    • @autisticbluesloth5244
      @autisticbluesloth5244 Рік тому

      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

    • @autisticbluesloth5244
      @autisticbluesloth5244 Рік тому

      to get wether or not a player is a certain distance you do (CapturePoint.Position - Character.Position).magnitude

  • @Aang600
    @Aang600 Рік тому

    These are so clutch tysm

  • @Martinchi
    @Martinchi Рік тому +61

    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.

    • @GamingDude467
      @GamingDude467 6 місяців тому

      YES

    • @TT_and_CuzT
      @TT_and_CuzT 6 місяців тому

      I agree GnomeCode is #1

    • @BrightDay-tb8jj
      @BrightDay-tb8jj 6 місяців тому

      gnomecode you are da goat when i am a millionaire roblox-developer you can have 1 dollar

    • @BrightDay-tb8jj
      @BrightDay-tb8jj 6 місяців тому

      btw ur website is blocked for some reason :(

  • @tist203
    @tist203 Рік тому

    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?

  • @scratchthat8230
    @scratchthat8230 Рік тому +1

    Best lua teacher!, A very calming voice too, Not a screechy 9 yr old, ty

  • @mogthelog
    @mogthelog Рік тому

    I love all the games u make ! Teddy is my favourite!

  • @mrminion545
    @mrminion545 Рік тому

    This is gonna be useful in my next game since its a long game!

  • @nickkingpiggy2651
    @nickkingpiggy2651 Рік тому +1

    This will be helpful and also I bought some of your merch

  • @BingusDev123
    @BingusDev123 Рік тому +2

    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?

  • @Bambuuck
    @Bambuuck Рік тому +1

    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!

  • @NeverEverFaceTheDark
    @NeverEverFaceTheDark 6 місяців тому

    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

  • @cryptex6709
    @cryptex6709 Рік тому

    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

  • @FuntimeAG
    @FuntimeAG 26 днів тому

    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.

  • @rein5614
    @rein5614 2 місяці тому

    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!

  • @sewie2620
    @sewie2620 Рік тому

    Yessir i needed this

  • @huy_nigera
    @huy_nigera 3 місяці тому

    Thank you, this really good working

  • @SergeantNooob
    @SergeantNooob Рік тому

    what a coincidence, I was just looking for videos about datastore

  • @Erolsaurus
    @Erolsaurus 10 місяців тому

    Thanks for the awesome tutorila!

  • @TheRecordium
    @TheRecordium Рік тому

    so helpful!

  • @SpleafYT
    @SpleafYT Рік тому

    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!

  • @redspy007
    @redspy007 Рік тому

    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?

  • @polfailice1401
    @polfailice1401 2 місяці тому

    Bro, u are the best teacher! I like to watching u. Sorry for my English 😅

  • @SirMemeV2
    @SirMemeV2 Рік тому

    great video

  • @cryptex6709
    @cryptex6709 Рік тому

    Bro this is insane

  • @Despacite
    @Despacite Рік тому

    amazing tutorial !

  • @aubriemason1239
    @aubriemason1239 Рік тому

    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

  • @jajaredgamer7462
    @jajaredgamer7462 Рік тому +1

    Cool video but why you don’t upload about teddy anymore?

  • @sapphiresky670
    @sapphiresky670 Рік тому +1

    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.

    • @KhalidBro
      @KhalidBro 11 місяців тому +3

      create it urself. he cant help u with everything

  • @panorocks1819
    @panorocks1819 Рік тому

    how do i edit it from other scripts? like add stuff to datastore (like dollars + 20) from another script?

  • @degeneradodoscomentaro_
    @degeneradodoscomentaro_ Рік тому +1

    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!

  • @plasma4970
    @plasma4970 Рік тому

    Soooo the tower range is broken. When you click on and off and sell it doesnt go away? Any fix?

  • @hydeharris2058
    @hydeharris2058 Рік тому

    Could you please consider doing a video on Ordered Data Stores?

  • @woke211
    @woke211 10 місяців тому

    such a helpful tutorial

  • @flision99
    @flision99 Рік тому

    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

  • @cloaker1903
    @cloaker1903 8 місяців тому +1

    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

  • @jaybird7667
    @jaybird7667 10 місяців тому

    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.

  • @roninexplode
    @roninexplode Рік тому

    Could you help with the footstep video? Nothing works when I do it all, not even the walking animation you made

  • @scratchthat8230
    @scratchthat8230 Рік тому

    That's great and all but how do you store a list of values that I can table.Insert() more values into?

  • @NukegamerboyRA
    @NukegamerboyRA Рік тому

    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

  • @I-TIMOT
    @I-TIMOT 10 місяців тому

    you earned ez subscribe, bro

  • @nightlightworld9964
    @nightlightworld9964 Рік тому +5

    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

    • @doinic09
      @doinic09 Рік тому

      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.

  • @kokskoksowy
    @kokskoksowy 11 місяців тому +1

    why does the console say:
    Argument 1 missing or nil

  • @TheOfficialPWP
    @TheOfficialPWP Рік тому

    also does this work for other data too like weapons,location etc

  • @Yan_Yan209
    @Yan_Yan209 Рік тому

    How do i save items from the datastore. Like i bought something in game and want to save it in my inventory . Please help

  • @Erolsaurus
    @Erolsaurus 10 місяців тому +1

    How would I add more values, though?

  • @kysics
    @kysics 2 місяці тому

    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

  • @AndriyRoblox
    @AndriyRoblox 11 місяців тому

    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)

  • @maleficentdemorgan
    @maleficentdemorgan 4 місяці тому

    OH IT WORKED TYSM

  • @Jappley
    @Jappley 10 місяців тому +2

    i dont know if i should feel insulted or honored when he calls me a gnome..

  • @phillkruegerjr1416
    @phillkruegerjr1416 Рік тому +1

    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?

    • @baconheadhair6938
      @baconheadhair6938 4 місяці тому

      just check the player coins when they touch the part

  • @Explosion_of_show-Dima
    @Explosion_of_show-Dima Рік тому

    a good lesson, but it would be nice to look at old materials

  • @PizzaMoose
    @PizzaMoose Рік тому

    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….

  • @ZeonWin
    @ZeonWin 3 місяці тому

    The changed event seems to not fire when the dollars is changed. Why is that?

  • @BasedOnBrian
    @BasedOnBrian Рік тому

    Can u make a tutorial on RunService bc I get confused all the time

  • @TheOfficialPWP
    @TheOfficialPWP Рік тому

    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?

  • @aguast4
    @aguast4 Рік тому

    for your next video could you modify and make droplets rpg kit more advanced? (for the kit just search up droplets modified rpg kit)

  • @7take93
    @7take93 2 місяці тому

    Thanks! How can I save data in multiple places within the game?

  • @shadowrobot77
    @shadowrobot77 Рік тому +1

    So.. Can i buy some data in data[Stores]?

  • @natsieee25
    @natsieee25 Рік тому

    GnomeCode i have something to ask you, can you make a game like steep steps, i really wanted a tutorial series for it..

  • @yeetboiaug9615
    @yeetboiaug9615 4 місяці тому +1

    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

  • @davidj-nv1sm
    @davidj-nv1sm 10 місяців тому

    thank you bro

  • @VarlMuN
    @VarlMuN Рік тому

    what about saving with item like multiple type of guns/weapons how to apply to it?

  • @itzdarkcy7141
    @itzdarkcy7141 Рік тому

    New series! "How to make a game like entry point" rn.

  • @SynTaxx1
    @SynTaxx1 11 місяців тому

    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

  • @KooIKid
    @KooIKid Рік тому

    do you know if you can make a murderer mystery type of game?

  • @bielortiz2166
    @bielortiz2166 3 місяці тому

    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?

  • @SeasonxRBLX
    @SeasonxRBLX Рік тому +1

    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!

  • @Firesy
    @Firesy 4 місяці тому

    Can you make a video on how to edit datastore manually?

  • @yourmomma7981
    @yourmomma7981 Рік тому +1

    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!

  • @Votaxyt
    @Votaxyt Рік тому

    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

  • @evil_pro_team9562
    @evil_pro_team9562 Рік тому

    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

  • @MoonLmao
    @MoonLmao Рік тому

    I've noticed the brightness in recent videos has been quite low- anyone know why?

  • @kattykillz
    @kattykillz Рік тому

    You should make a tutorial on how to add collectable gold into the Doors Tutorial series, I'd love to see it!

  • @itsrellw
    @itsrellw Рік тому +1

    Can you make a series of how to make a steep steps game..

  • @boi8756
    @boi8756 Рік тому

    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!

  • @koainanis5840
    @koainanis5840 Рік тому

    Hey GnomeCode did you stop the Doors Tutorials Series?🤔
    I am waiting for the next part...

  • @CerberusGaming0
    @CerberusGaming0 Рік тому

    gnomecode how do you make your horror monster work i watched the tutorial and its animating wont work

  • @jjjkdv542
    @jjjkdv542 4 місяці тому

    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.

    • @spiritblue5139
      @spiritblue5139 3 місяці тому

      same for me have you found the solution?