DataStore (Saving Player Data, pcall(), Scopes) - Roblox Advanced Scripting #17 (2024)

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

Komentáře • 179

  • @BrawlDevRBLX
    @BrawlDevRBLX  Před 3 měsíci +1

    🎁Get Access to my Scripts + More Perks by Becoming a Channel Member! 👇
    www.youtube.com/@BrawlDevRBLX/join

  • @AdityaPlays.lolpanti
    @AdityaPlays.lolpanti Před 6 měsíci +12

    Thank You soo much.
    Finding such detailed explanation is really hard to find, all the resources on CZcams are either too old or not so detailed.
    It is really a shame that this video still does not have the views it deserves

  • @cauasales32
    @cauasales32 Před 7 měsíci +5

    You're amazing. I'm from Brazil, english is not my first language but your teaching skills are fenomenal. I can understand pretty much everythin without needing to go back in the video, your oratory it's just too good! Thanks for the video and keep up with the hard work!

    • @BrawlDevRBLX
      @BrawlDevRBLX  Před 7 měsíci +5

      Happy to hear that you like my explanations and teaching style! I hope you stick around for the many videos I have planned for the future! :)

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

      I am Brazillian aswell and i toltally agree

  • @s1nblitz
    @s1nblitz Před 3 měsíci +1

    this was literally the only datastore tutorial that i fully understood and wasnt way too convoluted
    thank you soo much, this will bring my games to the next level

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

    Finally a tutorial on Data saving that ACTUALLY WORKS. I cannot tell you how many tutorials i've seen with the same not working code and no explaining done. You honestly deserve A whole lot more views and subscribers than you have.

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

    Was literally looking for one of these videos and have been following your tutorial. Youre awesome for that

  • @Shadows_Edits
    @Shadows_Edits Před 5 měsíci +2

    Thanks man your so underrated, you deserve more subs, keep up the good work!

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

    FINNALY!!!!! I now understand STUPID data stores after 3 years

    • @darkbard7
      @darkbard7 Před 29 dny +1

      3 years is mad😭😭😭

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

    Thank you for making these videos! They're easy to follow and extremely helpful! I've watched dozens of other videos but the way you explained the content made it feel very approachable. Thank you!

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

    literally the best datastore video I've seen, you explained it so well. Surprised to see you only have 5k subs

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

    i love your videos so much man, they have helped me to understand lua so much better and make me able to code things that i wouldn’t even have understood before watching your videos. you deserve so many more subs and you should definitely keep up the fantastic work!!!

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

    OMG I've done like 5 different tutorials and yours is the first that worked, and it also makes a lot of sense! Thank you so much for this video, it did a really good job of explaining how datastores work :D

  • @V1per1Real
    @V1per1Real Před 8 dny

    bro after so many tutorials yours is the one that actually worked for me u explained it good, nice job!

  • @spike9946
    @spike9946 Před 8 měsíci +2

    love the way you explain everything keep it up!

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

    compared to other videos, this video cleared up any mud I had about data stores and now data stores seem pretty simple. thank you! :)

  • @VeryProPlayerYesSir1122
    @VeryProPlayerYesSir1122 Před 8 měsíci +3

    Thy Hood only allow you to save 1 Shilling(other than that no datastore) but it still get popular.

  • @ZeroCrypher
    @ZeroCrypher Před 8 měsíci +1

    W tutorial, you lowkey helping me keep up that content 💯

  • @ItsCoderDan
    @ItsCoderDan Před 27 dny

    this is def the best explanation of datastores on CZcams

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

    this channel & video needs wayyy more hype!

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

    Bro dropped this👑

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

    Hey man you're a good teacher on Roblox Lua coding, I understand more now!
    I'm trying to make Incremental Game in the Player's Gui, I've been struggling with it.

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

    I was finding it so difficult to wrap my head around datastores, yet upon finding your video everything finally makes sense. Thanks alot 💯

  • @3AM04
    @3AM04 Před měsícem

    This is by far the best video on data stores. You explain it very well 🎉

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

    Thank you so much!!! i had a problem in my data, but this explanation help me so much!

  • @kuanjarlo
    @kuanjarlo Před 2 měsíci +1

    HOLY CRAP I JUST REWATCHED THIS THE NEXT DAY AND I FINALLY GET THE LOGIC THANK U SM BRAWLDEV

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

    I started here but like 15 minutes in realized there's prerequisite information I'm missing and will now be going on an adventure to watch this full series, also subscribed because the way you teach this just clicks in my brain, Thank You!

  • @Jumpcraftt
    @Jumpcraftt Před 8 měsíci +4

    Good Video, but if i can ask, how i can save player data of things, like the tycoon at start?

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

    The way you teach in these videos is just amazing to me ngl

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

    Rare underrated youtuber guys better than devking and many other scripting youtubers. Actually explains what the datastore store is doing, helped me a ton. Respect g 👊

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

    yo I just love how this dude conceptualizes.

  • @Ken_Dev
    @Ken_Dev Před 6 měsíci +42

    Better than DevKing!

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

      True

    • @mwnda
      @mwnda Před 6 měsíci +11

      fr, dude says ummm after every other word lmao

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

      LMAO trueee@@mwnda

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

      real

    • @CherryTree277
      @CherryTree277 Před 4 měsíci +11

      Dont disrespect the goat like that.. his tutorials was back at 2019 when theres barely anythin on youtube

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

    i can easily say that i will be able to use datastores with ease from now on because of how wonderfully you explained

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

    Thank you so much !! I usually have difficulties to stay focus, but the way youre teaching coding really helps me a lot !!!! And i also want to learn more !!!

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

    finally. was waiting for this

  • @King100Game
    @King100Game Před 8 měsíci +1

    Good one man how about strings next like
    string.match
    string.split
    string.find

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

    What a complete video. GOAT

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

    I really needed this thanks!

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

    Good Video. Wish you would have added a version number of DataStore. So that in creating a game and you want to reset your numbers back to a brand new player starting over. You can just change that number. I have seen it before. But don't get the jist of how it works.

  • @no-li4mr
    @no-li4mr Před 7 měsíci

    Great work dude keep it up

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

    I wish you gave more information about scopes. In most large projects, it won't be single values being saved, ie cash. The Documentation info about scopes is trash, and it is hard to know how to save large amounts of varying types of data, while being organized and concise. I also feel like leaderstats aren't a good indication of advanced data store usage either, considering as I stated earlier, most projects will not be saving just a few IntValues as data.

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

      right, I am trying to learn how to save and load someone's backpack

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

      @@ItsVegaSama Do you have an account on the devforum? I can send you a script I made to do that if you are interested? I can try and explain it in the comments, but it's probably too long for that.

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

      @@imthebestmayne122 Please help me too. User is Supercool_dd

  • @dereineuncoole
    @dereineuncoole Před 9 dny +1

    I dont understand how the if success then part works, what is success?? how can it be true or not I just dont get it

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

    You make the vid fun and understandable goated and underrated fr

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

    Wonderful!

  • @user-lt2dc9eg8m
    @user-lt2dc9eg8m Před 5 měsíci

    Amazing explaination

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

    Many thanks✌️

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

    im using player.UserId as key and sometimes i use TableName[player.UserId] or TableName[player.UserId].ValueName.Value , but this was really helpful! :)

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

    could you create two different functions inside a module script to handle the saving and loading of player data and then require it from a server script? Just to keep things more organized?

  • @AndrewRoberts-ty9qy
    @AndrewRoberts-ty9qy Před 3 měsíci +1

    I have been having an issue that I’ve been trying to figure out to so long. My data store works fine, but when I publish an update from studio it seems to reset that date entirely not matter how much I try to fix it. Anyone know how to help? I am also still trying to find scripture to help me with my game.

  • @patpace
    @patpace Před 9 dny

    Playing catweb helped me on this video lol (It's a roblox block scripting game)

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

    Thank You , Now İ Can Make My DataStore Without Toolbox !!

  • @mustafaalabrashi8932
    @mustafaalabrashi8932 Před 5 dny

    you 're better than TheDevKing ❤

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

    when i try that increment async code it keeps saying "Unable to cast value to Object" can u help me with that?

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

      Im not sure if you put a datastore into a object, and if you did, then it wouldnt work, also datastores are inside leaderstats scripts so you would open up your leaderstats script, press the + button and add another script which would be the datastore

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

    datastores is a nightmare

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

    goooaaaattt

  • @Sam-gm8qf
    @Sam-gm8qf Před 2 měsíci

    "gonna get Very Very Very Very disorganised Very Very fast..."
    The famous words of BrawlDev aka BrawlBattle.

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

    WHAT A VIDEOS I LOVE U

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

    haven't watched the full video yet, but according to your timestamps you used setAsync, wouldn't updateAsync be better as it lessens data losses?

  • @user-xo9fz2zt8m
    @user-xo9fz2zt8m Před 2 měsíci

    did it take me a while to understand yes, was it worth it, your god damn right it was

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

    i am brazilian and i loved your movie

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

    I got an idea for vidoe: Make a toolbar/hotbar with draggable icons etc.

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

    Thanks buddy

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

    a good use for remove async is when u ban players

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

    I think i get it now. Doesnt pcall return one value. True or false. That's success right? Then the second return value which is currentCoins depends on what you return in the function which in the case you did PlayerCoins:GetAsync(player.UserId) Correct me if im wrong.

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

    Nice... but how do you manage dynamic JSON-like data? like:
    [
    {"player1":
    {
    "inventory":
    [
    {
    "item_id": 4,
    "qty": 50
    },
    {
    "item_id": 2,
    "qty": 4
    }
    ]
    }
    },
    {"player2":
    {
    "inventory":
    {
    "item_id": 5,
    "qty": 10
    }
    }
    }
    ]

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

    Bro at 28:26 when he calls increkmentvalue, what do we put in the parentheses? I am getting an error message because I don't have anything in them.

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

    Do you have any recommendations for any good books on Roblox development?

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

      I’ve never read any books on Roblox development, but I’ve heard “Heath Haskins
      The Advanced Roblox Coding Book: An Unofficial Guide, Updated Edition” is a popular pick.

  • @AggelosKriaras-zq3eq
    @AggelosKriaras-zq3eq Před 6 měsíci

    Should i declare a data store as "PlayerData" and set it as a huge table with diff types of data such as leaderstats settings inventory etc? Or should i separate the data into different datastores? Also in order to avoid any errors and data loss with pcall do the job? Thank you for the tutorial.

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

      I would usually have a main datastore like "PlayerData" and I would use scopes to categorize the datastore like "Inventory", "Leaderstats", "Settings", "EquippedStats", etc. As for pcall, it guarantees a response if fetching the data fails, but it doesn't prevent it. You must take extra steps to retry the data fetching if it fails. There are examples of this online, but I hope this helps you!

    • @AggelosKriaras-zq3eq
      @AggelosKriaras-zq3eq Před 6 měsíci

      Thank you very much for the response!

  • @Ambush715
    @Ambush715 Před 2 měsíci +1

    but thanks for the tutorial tho.
    i kind of get it.
    i just need some practice

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

    this is a nightmare

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

      True:(
      It's fucking confusing

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

    43:33 Maybe I understood it wrong, but wouldn't updating the date every minute be bad? What if a player leaves before that minute sets in? Do we double-check it with Players.PlayerRemoving?

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

      A mix of both is generally good for safety measure. The server could shut down abruptly, which wouldn't could towards the PlayerRemoving event and then progress would be lost. If you want to, you can change the wait time from 60 secs to something like 5 or 10 minutes.

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

    Hmm interesting that async calls are awaited automatically.

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

    so UpdateAsync will automatically retry if success is false and keep retrying until it's true?

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

    Hey brawldev sometimes it doesn't save because the server shuts down too quickly how do fix that

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

    43:47 I dont understand, what do i put inside the loop to save the data every 60 seconds?

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

    what about the gui? like data gui? like if player touch the part and frame will visible and if player leave the game and join again the frame is still visible can you make that?

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

      yes, so create a value in the player, example “frame” and set it to 0, when the player touches the frame, set it to 1, and save that value, and also make in the frame script, for when the player joins, check to see if the frame value is one, and if it is open the frame, and save the “frame value” and there you go!

  • @user-yo4pj2me2v
    @user-yo4pj2me2v Před měsícem

    It's pretty good tutorial, but how you save player income per click?

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

    Hi, thanks for the very informative video, I'm struggling a bit to get my head around this as I want to keep my userdata in a dictionary, and then just update the whole dictionary to datastor when the player leaves, or recall the whole dictionary when the player logs on. The first problem I run into is when I try to parent the leaderstats folder to my dictionary, and since this is a necessary first step I can't progress further. Any help would be much appreciated. Please let me know if I should add in my code.

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

    Can you make a datastore that saves StarterCharacter clothes?

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

    i don't think you should use variable with the same name in the same scope, you're using success few times

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

    W vid

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

    Why do we return get async though? Why not just use get async on its own.

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

    ANYONE, BEAR IN MIND!!!
    if your datastore isnt working (doesnt matter, yours or tutorial but it wrote right) you can publish your place to roblox and test yourdatastore script, someone have this bug (like me), this is a solution

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

    Question, why not make values in the game and when the player leaves, it sets the values to the datastore instead of directly setting the value to the datastore?

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

    isnt using userId better for keys in datastore? if a player changes their username they would lose all of their data, for example

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

      Correct! UserId cannot change for a user so that's better to use as a key.

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

    my brain cant handle this .. i need help 😭😭😭

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

    datastores are fucking confusing

  • @gg-nv1mq
    @gg-nv1mq Před 4 měsíci

    I knew how to use data store and I got confused after this video :/

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

    hi there do you know how u can make it so if a player reaches a specific place for ex. i have a backrooms game and a player reaches level 2. how do i make it so that when they rejoin they spawn into level 2?

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

      You can save(PlayerLeaving) on which level the player is at the moment then add load on playeradded. Other script on playerAdeed if the value of current level == 2 they should get teleported there or something.

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

      @@konvro damn thank u bro

  • @gamerrobloxloles8893
    @gamerrobloxloles8893 Před 21 dnem

    How would I set it without increasing it by ten. I gave myself 200 coins, but instead, I got 30 after loading back in can someone help

    • @Triploonic
      @Triploonic Před 14 dny

      Thats strange, did you set your money while on the client? (I made that mistake One too many time back then...)

    • @gamerrobloxloles8893
      @gamerrobloxloles8893 Před 14 dny

      @@Triploonic thanks I got it to work

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

    When I put this into my script it doesn’t save data the only thing it says value cannot be converted to a number

    • @no-li4mr
      @no-li4mr Před 6 měsíci

      Are you trying to save numbers or strings (text)?

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

      Are you trying to save an IntValue?

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

      I'm having the same problem

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

    how do make it so that the number doesn't increase by 10 instead it will save the number of cash u got?

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

      i was legit thinking the same thing but bro did you found out how pls tell me if you did

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

    Saving spot 20:19

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

    This mf can teach math in fortnite terms

  • @YenzoDev
    @YenzoDev Před 11 dny

    OH MY GOOOSHSHSHSHSHSSHSHSH TYSMM

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

    Hello, may I know how to reset the data of all players? please

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

      Try looking into ListKeysAsync, you should be able to reset all the data with a for loop

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

    first

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

    WHERE IS SCRIPTS

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

    pcalls are confusing

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

    did everything you did, but when i run it it says "value of type nil cannot be converted to a number" - can you help me please?

    • @Ahmed.Esmail2169
      @Ahmed.Esmail2169 Před 5 měsíci

      you might made the coins other Value than intValue make sure it is a intValue to accept the number

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

      @@Ahmed.Esmail2169 nah, it fixed after I ran it by using game.players.playeradded, but didn't after characteradded idk why that's a thing

    • @Ahmed.Esmail2169
      @Ahmed.Esmail2169 Před 5 měsíci

      @@abenex2175 pro I don't understand any thing when he made pCall() and started sitting functions like setAsync and updateAsync what pCall() is??

    • @abenex2175
      @abenex2175 Před 5 měsíci +2

      @@Ahmed.Esmail2169 a pcall writes to 2 variables, first being a Boolean which checke if the function in the pcall was successful, and the 2nd outputs the potential error message if the pcall wasnt successful. If there's a return statement in the function, the output will go to the 2nd variable instead

    • @Ahmed.Esmail2169
      @Ahmed.Esmail2169 Před 5 měsíci

      @@abenex2175 alright I understand that but why do he setAsync with pCall that doesn't mean if you collect coins at the game and get out then play the game again the value of coins will be the value he sitted and the coins you collected will be gone ?

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

    how do you do repeats tho?

    • @Kaizagidora
      @Kaizagidora Před 23 dny

      local function DataStoreGrabber()
      local FailCounter = 1
      local Success, ErrorMessage
      repeat
      Success, ErrorMessage = pcall(function()
      -- Your code here
      -- For example: someFunctionThatMightFail()
      end)
      if not Success then
      print("Error: " .. ErrorMessage)
      end
      FailCounter = FailCounter + 1
      until Success or FailCounter > 5
      if not Success then
      -- if it didn’t after 5 tries
      print("Failed after 5 attempts: " .. ErrorMessage)
      else
      -- if it got through
      print("Success!")
      end
      end