Save Player Data with Roblox Datastores

Sdílet
Vložit
  • čas přidán 27. 08. 2024

Komentáře • 651

  • @huttle
    @huttle Před rokem +185

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

    • @ummmyah
      @ummmyah Před rokem +4

      Oh most definitely

    • @Giuyo
      @Giuyo Před rokem +4

      yes it's an awesome thing.

    • @BasedOnBrian
      @BasedOnBrian Před rokem +10

      Better than TheDevKing

    • @TheOfficialPWP
      @TheOfficialPWP Před rokem +4

      yea the others are unhelpful

    • @wolf9903
      @wolf9903 Před rokem +2

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

  • @Martinchi
    @Martinchi Před rokem +61

    Out of the many CZcamsrs 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.

  • @GigaGnome
    @GigaGnome Před rokem +16

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

  • @Kaizentry
    @Kaizentry Před rokem +14

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

  • @keeguri
    @keeguri Před rokem +15

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

  • @halalouis3814
    @halalouis3814 Před rokem +13

    The Script:
    local Players = game:GetService("Players")
    local RunService = game:GetService("RunService")
    local DatastoreService = game:GetService("DataStoreService")
    local database = DatastoreService:GetDataStore("PlayerData")
    local sessiondata = {}
    local DefaultData = {

    ["Dollars"] = 50

    }
    local function PlayerAdded(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"

    local Dollars = Instance.new("NumberValue", leaderstats)
    Dollars.Name = "Dollars"


    local sucsess = nil
    local PlayerData = nil
    local attempt = 1
    repeat
    sucsess,PlayerData = pcall(function()
    return database:GetAsync(player.UserId)
    end)
    if not sucsess then
    warn(PlayerData)
    task.wait(3)
    end
    attempt += 1
    until sucsess or attempt == 5

    if sucsess then
    print("Connected To Database")

    if not PlayerData then
    print("No User Data Found, Assigning Default Data")
    PlayerData = DefaultData
    end
    sessiondata[player.UserId] = PlayerData

    else
    warn("Unable To Get Data For User: "..player.Name)
    player:Kick("Unable To Load Your Data, Please Try Again Later! :D")
    end

    Dollars.Value = sessiondata[player.UserId].Dollars -- SYNC LEADERSTATS WITH DATASTORE
    Dollars.Changed:Connect(function()
    sessiondata[player.UserId].Dollars = Dollars.Value
    end)
    leaderstats.Parent = player


    end
    local function PlayerRemoved(player)
    if sessiondata[player.UserId] then
    local sucsess = nil
    local errorMsg = nil
    local attempt = 1

    repeat
    sucsess, errorMsg = pcall(function()
    database:SetAsync(player.UserId, sessiondata[player.UserId])
    end)

    if not sucsess then
    warn(errorMsg)
    task.wait(3)
    end

    attempt += 1
    until sucsess or attempt == 5

    if sucsess then

    print("Data Saved For User: "..player.Name)

    else
    warn("Data Unable To Save For User: "..player.Name)

    end

    end
    end
    local function ServerShutdown()

    if RunService:IsStudio() then
    return
    end

    print("Handling Server Shutdown")
    for i, plr in ipairs(Players:GetPlayers()) do
    task.spawn(function()
    PlayerRemoved(plr)
    end)
    end
    end
    Players.PlayerAdded:Connect(PlayerAdded)
    Players.PlayerRemoving:Connect(PlayerRemoved)
    game:BindToClose(ServerShutdown)

    • @daog_beast4151
      @daog_beast4151 Před rokem

      bro your a legend tysm

    • @halalouis3814
      @halalouis3814 Před rokem

      @@daog_beast4151 no problem, btw if you need help scripting just ask me, i have quite a lot of experience

    • @Erolsaurus
      @Erolsaurus Před rokem

      @@halalouis3814 How would I add another leaderstat to this?

    • @Erolsaurus
      @Erolsaurus Před rokem

      @@halalouis3814 Now I'm confused. I added a second leaderstat and it worked, but I added a third one and the script stopped working. I went back to two, but it also didn't work.

    • @halalouis3814
      @halalouis3814 Před rokem

      @@Erolsaurusmight be because roblox loads and unloads things weirdly, try using multi-threading

  • @bisoncool1215
    @bisoncool1215 Před rokem +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 Před rokem +2

      He already did that with lobby elevator video

    • @GreatRamilYT
      @GreatRamilYT Před rokem

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

    • @KoalaOnYT_
      @KoalaOnYT_ Před rokem

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

    • @KoalaOnYT_
      @KoalaOnYT_ Před rokem

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

    • @GreatRamilYT
      @GreatRamilYT Před rokem

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

  • @mr_griffolukegriffiths9166

    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  Před rokem +19

      Excellent points, thanks griffo

    • @GalaxyedRainbow
      @GalaxyedRainbow Před rokem +5

      @@GnomeCode your cool i like you

    • @LuminousLynxz
      @LuminousLynxz Před rokem +2

      @@GnomeCode Can you make more doors?

    • @onewill8905
      @onewill8905 Před 10 měsíci +6

      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 Před 10 měsíci

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

  • @YuinAstrophel
    @YuinAstrophel Před rokem +5

    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.

  • @azura_alien
    @azura_alien Před rokem +4

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

  • @DaAccountName
    @DaAccountName Před rokem +4

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

  • @Ironbaby08
    @Ironbaby08 Před rokem +4

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

  • @giraffeplays7065
    @giraffeplays7065 Před rokem +3

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

  • @waffle_doge5594
    @waffle_doge5594 Před rokem +4

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

  • @2_toastedbagels
    @2_toastedbagels Před rokem +1

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

  • @scratchthat8230
    @scratchthat8230 Před rokem +1

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

  • @Afarmcow
    @Afarmcow Před 10 měsíci +5

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

  • @MadnessNull
    @MadnessNull Před rokem +3

    I said im gonna look up datastores and this video notif poped up
    Gnome did you put cameras in my room!??! /j

  • @dunialajla
    @dunialajla Před 6 měsíci +1

    Great Video! I learnt a lot from this channel

  • @RichRBLX
    @RichRBLX Před rokem

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

  • @lolofuk87
    @lolofuk87 Před rokem

    Thank you sir, never seen before the repeat until implementation

  • @hattinnh
    @hattinnh Před 2 měsíci

    Thank you for posting - learnt a lot!

  • @FuntimeAG
    @FuntimeAG Před 3 měsíci

    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.

  • @AlanShogs56
    @AlanShogs56 Před 7 měsíci

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

  • @epicfriez
    @epicfriez Před rokem +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 Před rokem

      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 Před rokem

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

  • @Jappley
    @Jappley Před rokem +2

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

  • @vroomgt5743
    @vroomgt5743 Před 4 dny

    This really helps for my game👍

  • @BingusDev123
    @BingusDev123 Před rokem +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?

  • @cryptex6709
    @cryptex6709 Před rokem

    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

  • @alex965t9
    @alex965t9 Před rokem +1

    I love your content man
    i learn a lot

  • @7a8a13a5
    @7a8a13a5 Před rokem

    yes the plugin edit video sounds great too :)

  • @degeneradodoscomentaro_
    @degeneradodoscomentaro_ Před rokem +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!

  • @polfailice1401
    @polfailice1401 Před 5 měsíci

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

  • @nightlightworld9964
    @nightlightworld9964 Před rokem +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 Před rokem +1

      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.

  • @maaloyy_
    @maaloyy_ Před rokem

    You are helping so much! Liked and followed you!

  • @twizzitch3127
    @twizzitch3127 Před rokem +2

    Hey GnomeCode! I know it has been a month, and I don't know if anybody had asked this, but are you able to make a Murder Mystery type series?

  • @SergeantNooob
    @SergeantNooob Před rokem

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

  • @nickkingpiggy2651
    @nickkingpiggy2651 Před rokem +1

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

  • @1TSAMELIAA
    @1TSAMELIAA Před rokem

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

  • @blandpotato545
    @blandpotato545 Před rokem +3

    The script isn’t working for me. I copied everything in the script but it won’t save the cash value in my leaderstats between games

    • @diphenylmethane
      @diphenylmethane Před rokem

      same it just randomly decides when to save and always loads the default data only

    • @baconheadhair6938
      @baconheadhair6938 Před 6 měsíci

      then you didn’t do it correctly brother

  • @alejandrorivera9694
    @alejandrorivera9694 Před rokem +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?

  • @mrminion545
    @mrminion545 Před rokem

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

  • @SandrockYT
    @SandrockYT Před měsícem

    Amazing tutorial! earned a like and sub

  • @AndersonDosGames
    @AndersonDosGames Před rokem +1

    i accidentally closed the tab which i had this video open in and when i came back it was on the part where it was when i closed it, i guess youtube knows how to use Datastores too

  • @Hyxerin
    @Hyxerin Před 22 dny +1

    it doesnt work, I leave then rejoin and the data is the base value

  • @IndevGames-sl9np
    @IndevGames-sl9np Před měsícem

    This guy is a goat tysm!

  • @joncepearce7293
    @joncepearce7293 Před 13 dny

    What if setting the player's data fails all five attempts? Isn't it safer to not check the attempt number at all?

  • @itzdarkcy7141
    @itzdarkcy7141 Před rokem

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

  • @sapphiresky670
    @sapphiresky670 Před rokem +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 Před rokem +3

      create it urself. he cant help u with everything

  • @NeverEverFaceTheDark
    @NeverEverFaceTheDark Před 8 měsíci

    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

  • @Aang600
    @Aang600 Před rokem

    These are so clutch tysm

  • @PizzaMoose
    @PizzaMoose Před rokem

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

  • @27op0qks
    @27op0qks Před rokem

    Hey GnomeCode, could you make a video with my suggestion? It's because i'm making a roblox horror game. There is a monster that will teleport around the map with 1 minute wait time, and when you look at it, it will pop up in your screen, play a sound and fade away.(I'm still a begginer in roblox studio, thats why i ask talented people like you!)

  • @plant148
    @plant148 Před rokem +1

    doors questions :
    how do you make a Ambush Monster AI?
    how do you make a room spawn when you reach lets say door 50?
    how do you make the eyes monster AI?
    how do you make the Ghost/Halt monster AI?
    how do you make eyes apper on the walls when you reach door 30-40?
    how do you make the heartbeat minigame?

  • @SafixBG
    @SafixBG Před rokem +1

    Hello GnomeCode! Remember when you did tutorials on how to make Doors Roblox? So... Can you make new Doors tutorials? Doors just added Crucifix, Skeleton Key, etc. Can you make tutorials?

    • @ghostlyn69
      @ghostlyn69 Před rokem

      You could of just said “hey gnomecode how can I fully rip off doors with nothing original”

    • @doinic09
      @doinic09 Před rokem

      @@ghostlyn69 trueee

  • @yourmomma7981
    @yourmomma7981 Před rokem +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!

  • @jajaredgamer7462
    @jajaredgamer7462 Před rokem +1

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

  • @Slimedev56
    @Slimedev56 Před 7 měsíci +1

    TIP: if the code is not working, MAKE SURE you typed everything correctly, even the tiniest of errors could cause the script to fail.

    • @jstarandomdude
      @jstarandomdude Před 7 měsíci +1

      on the sample script he made (the one that makes dollars on the leaderboard appears) mine doesnt work? I even tried running print to see where it fails but it runs print meaning it just refuses to make folder called instance

    • @aqaisback9517
      @aqaisback9517 Před 6 měsíci

      leaderstats HAS TO BE NAMED "leaderstats" otherwise it will not work@@jstarandomdude

  • @alejandrorivera9694
    @alejandrorivera9694 Před rokem +1

    it's been a month since he uploaded this video...

  • @MrPablo-uf5zr
    @MrPablo-uf5zr Před rokem +1

    i have a hint: you can make teddy a camera part in front of him and then do script add remote event in replicatestorge and then put local script and script it that is: local player = game.Players.LocalPlayer
    local character = player.Character
    local ph = character:WaitForChild("Humanoid")
    local cam = workspace.CurrentCamera
    game.ReplicatedStorage.Jumpscare.OnClientEvent:Connect(function()
    cam.CameraType = Enum.CameraType.Scriptable
    cam.CFrame = workspace.Teddy.CameraPart.CFrame
    workspace.Teddy.HumanoidRootPart.Anchored = true
    wait(2)
    workspace.Teddy.HumanoidRootPart.Anchored = false
    cam.CameraType = Enum.CameraType.Custom
    end) make sure to put in teddyai when player health = 0 put fire event of the replicatestorge Jumpscare

  • @kattykillz
    @kattykillz Před rokem

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

  • @aubriemason1239
    @aubriemason1239 Před rokem

    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

  • @WolfManZ383
    @WolfManZ383 Před měsícem

    It didn't work for me... I leave and rejoined and it didn't save my data

  • @mehmetemindurmus6616
    @mehmetemindurmus6616 Před rokem +1

    didnt work can you help me

  • @itsrellw
    @itsrellw Před rokem +1

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

  • @_-Froggy-_
    @_-Froggy-_ Před rokem +1

    I have an I for a new tutorial series it should be about the Roblox game Bigfoot by black spruce studio or you could do a monster island game if it's possible

  • @breadCaves
    @breadCaves Před 5 měsíci +1

    Sadly, the data isnt saving for some reason and it always makes it the default value.

    • @roatninthethird
      @roatninthethird Před 5 měsíci

      you made a mistake somewhere in your code

    • @jerrypilkles
      @jerrypilkles Před 5 měsíci

      @@roatninthethird no it just doesn't save even if you copy it word for word

    • @roatninthethird
      @roatninthethird Před 5 měsíci

      @@jerrypilkles worked for me

    • @flision99
      @flision99 Před 4 měsíci

      @@roatninthethird Mine is giving the ErrorMsg when leaving the game

    • @roatninthethird
      @roatninthethird Před 4 měsíci

      @@flision99 i already gave up on coding, you're on your own

  • @huy_nigera
    @huy_nigera Před 6 měsíci

    Thank you, this really good working

  • @boi875_RBLX
    @boi875_RBLX Před rokem

    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!

  • @gigga2499
    @gigga2499 Před rokem +1

    GnomeCode please make a hungry pig game pls

  • @elmerald210
    @elmerald210 Před rokem +1

    you probably wont see this, but can you make a ambush ai for the doors tutorials.

  • @blackkray.
    @blackkray. Před rokem +1

    I am interested in a standalone for editing datastores! Please gnomecode!!! Love your content btw!

  • @mrtmrv5873
    @mrtmrv5873 Před rokem +1

    Can you make a shooter game series?

    • @alejandrorivera9694
      @alejandrorivera9694 Před rokem

      He needs to finish doors series first

    • @J3RiC3LL
      @J3RiC3LL Před rokem

      That is actually a great idea I hope he does :) maybe after that he can maybe make a combat game like a sword fight game

  • @SeasonxRBLX
    @SeasonxRBLX Před rokem +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!

  • @JOSUETUBER08
    @JOSUETUBER08 Před rokem +1

    GnomeCode make vídeo like: How to make doors delete past rooms and generate more. Like this

  • @ExtraFerance
    @ExtraFerance Před rokem

    hes most likely on a hiatus on youtube, hes still active on roblox so dont worry.

  • @Eltoxxx
    @Eltoxxx Před 9 měsíci +1

    I dont want all of the data to be a leaderstat tho

  • @4DF2007Official
    @4DF2007Official Před rokem

    ngl gnome code is easy to understand because he speaks at a normal pace, compared to the “oksotodaywehavethedatastore”

  • @Bambuuck
    @Bambuuck Před 20 dny

    So, I had a question which appeared after I implemented the script into my game (Great tutorial!), the question is how do I modify those leaderstats using other scripts? e.g. I got a leaderstat which is called "Tutorial completed" and its a boolValue and should become true when my tutorial is completed.

  • @decentlookin
    @decentlookin Před měsícem

    my man Gnome; helpful as ever. whoever, me n' u both, r british, why you be needing 500 finest dollars.

  • @TheRecordium
    @TheRecordium Před rokem

    so helpful!

  • @dickthecat7470
    @dickthecat7470 Před rokem +1

    BRO FFS DONT DO THIS THING WHERE WE TRY FIND ERRORS ALONG THE WAY IT JUST MAKES IT MORE CONFUSING WHEN WE ARE GOING THROUGH AND IS SCREWS MY NOTES

    • @TheMaxGuy
      @TheMaxGuy Před rokem

      it makes it a bit easier for a lot of people to understand why they are getting errors in the first place

    • @dickthecat7470
      @dickthecat7470 Před rokem

      @@TheMaxGuy nuh uh

  • @natsieee25
    @natsieee25 Před rokem

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

  • @Explosion_of_show-Dima

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

  • @aydreytherat
    @aydreytherat Před rokem +1

    I followed every step and it didnt work

  • @Bambuuck
    @Bambuuck Před rokem +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!

  • @MythicMemorys
    @MythicMemorys Před 7 měsíci +1

    If anyone’s watching this a year later and can help I’m confused on what the variable sessiondata does. How are we checking if there is anything inside the sessiondata variable connected to the player when it’s just sessiondata = {}

    • @Thomasis5
      @Thomasis5 Před 7 měsíci +1

      "{}" is used to make a "table"
      I sadly can't help much, because I'm not very good with so called "tables"
      I just know that "tables" is used to store multiple stuff inside which you can use later on in scripts
      Hope it helped ;)

    • @MythicMemorys
      @MythicMemorys Před 7 měsíci

      @@Thomasis5 I know what a table is lol im not new to scripting im just confused on how we inserted the player.UserId inside of the sessiondata Variable

    • @Thomasis5
      @Thomasis5 Před 7 měsíci

      @@MythicMemorys Ok, my bad😅

    • @TheGenesis1223
      @TheGenesis1223 Před 5 měsíci

      so basically, in the loading script it sets the default values to the players session data, and the saving script reads it, and saves it. and from now on, your player session data will have data in it

  • @PewPewBoi
    @PewPewBoi Před rokem +1

    Hey i watching you since this channel 12k Please can you contuine the doors tutorial? Like: Seek, figure, objects, animations, Lobby. Maybe some people can do the other thing i can too but i cant make the seek ai and chase sceen same as tools to like lighters spawning in closets.
    I know you will do what you fans want.
    You are best.

  • @3dsman65
    @3dsman65 Před rokem +2

    on the next doors video can you show how to generate rooms at a specific door? like how the figure room generates at door 50.

    • @3dsman65
      @3dsman65 Před rokem

      PLEASE REPLY IF YOU ARE!!!!!! YOU ARE THE BEST CODER EVER!!!!!!!

    • @ghostlyn69
      @ghostlyn69 Před rokem

      If room == 51 then
      newroom = rooms.Library:Clone()
      end
      Yeah that simple.

    • @3dsman65
      @3dsman65 Před rokem

      @@ghostlyn69 yeah but which script?

    • @ghostlyn69
      @ghostlyn69 Před rokem

      @@3dsman65 room module script duh

    • @3dsman65
      @3dsman65 Před rokem

      @@ghostlyn69 because it doesn't work

  • @scratchthat8230
    @scratchthat8230 Před rokem +1

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

  • @souze3263
    @souze3263 Před rokem +2

    When I join for the first time, it prints 'Connected to database' but not 'Assigning default data' and it doesn't seem to save
    Incase you need the script,
    local sessionData = {}
    local DatastoreService = game:GetService("DataStoreService")
    local database = DatastoreService:GetDataStore("data")
    local Players = game:GetService("Players")
    Players.PlayerAdded:Connect(function(Player)
    local Folder = Instance.new("Folder")
    Folder.Parent = Player
    Folder.Name = "Stats"

    local Shrine = Instance.new("StringValue")
    Shrine.Parent = Folder
    Shrine.Name = "Shrine"

    local Faction = Instance.new("StringValue")
    Faction.Parent = Folder
    Faction.Name = "Faction"

    local Weapon = Instance.new("IntValue")
    Weapon.Parent = Folder
    Weapon.Name = "Weapon"

    local success = nil
    local playerData = nil
    local attempt = 1

    repeat
    success, playerData = pcall(function()
    return database:GetAsync(Player.UserId)
    end)
    attempt += 1
    if not success then
    warn(playerData)
    task.wait(3)
    end
    until success or attempt == 5

    if success then
    print("Connected to database!")
    if not playerData then
    print('Assigning default data')
    playerData = {
    ["Shrine"] = "",
    ["Faction"] = "",
    ["Weapon"] = 0
    }
    end
    sessionData[Player.UserId] = playerData
    else
    warn("Unable to get data for", Player.Name)
    Player:Kick("Unable to load your data...")
    end
    Shrine.Value = sessionData[Player.UserId].Shrine
    Shrine.Changed:Connect(function()
    sessionData[Player.UserId].Shrine = Shrine.Value
    end)
    Faction.Value = sessionData[Player.UserId].Faction
    Faction.Changed:Connect(function()
    sessionData[Player.UserId].Faction = Faction.Value
    end)
    Weapon.Value = sessionData[Player.UserId].Weapon
    Weapon.Changed:Connect(function()
    sessionData[Player.UserId].Weapon = Weapon.Value
    end)
    end)
    function PlayerLeaving(player)
    print(player, "is leaving")
    if sessionData[player.UserId] then
    local success = nil
    local errorMsg = nil
    local attempt = 1

    repeat
    success, errorMsg = pcall(function()
    database:SetAsync(player.UserId, sessionData[player.UserId])
    end)
    attempt += 1
    if not success then
    warn(errorMsg)
    task.wait(3)
    end
    until success or attempt == 5

    if success then
    print("Data has been saved for the one and only", player.Name)
    else
    warn("Sadly unable to save for the one and only", player.Name)
    end

    end
    end
    game.Players.PlayerRemoving:Connect(PlayerLeaving)

    • @nxbid
      @nxbid Před 10 měsíci

      holy thank you

    • @nxbid
      @nxbid Před 10 měsíci

      wait this isnt the script

    • @souze3263
      @souze3263 Před 10 měsíci

      nvm
      @@nxbid

  • @TheCaptainGooey
    @TheCaptainGooey Před rokem

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

  • @Erolsaurus
    @Erolsaurus Před rokem

    Thanks for the awesome tutorila!

  • @AQUArblx-fi2ol
    @AQUArblx-fi2ol Před 6 měsíci +1

    but how do i can save my progress without leader stats

  • @dreflox
    @dreflox Před měsícem

    during the PlayerAdded function, the "warn(playerData)" line after the pcall function to load player data throws "Argument 2 missing or nil".
    wat do?

    • @dreflox
      @dreflox Před měsícem

      nevermind i'm silly i copied the code from PlayerLeaving and i left SetAsync instead of GetAsync. All good :) great vid btw

  • @medinetekgoz
    @medinetekgoz Před rokem +1

    teddy how to get toy dice

  • @joemama-vo5ew
    @joemama-vo5ew Před rokem

    Hello GnomeCode, i saw that you have made a horror game like piggy recently, and i wanted to do that too, but i saw somethings are missing on the tutorials that i do need, thing like how a player gets selected as the monster, how the coin system works, how you can buy new skins, map voting stuff like that, so can you please make tutorials for that or help me out on my game, already big thanks🙂

  • @cryptex6709
    @cryptex6709 Před rokem

    Bro this is insane

  • @kokskoksowy
    @kokskoksowy Před rokem +1

    why does the console say:
    Argument 1 missing or nil

  • @bigbengamer5759
    @bigbengamer5759 Před rokem

    buddy... where did the doors tutorials go?!? No rush but I'm still very excitedly waiting. Get it, no rush... because that's the name of the doors monster... nvm