Data Stores - Roblox Scripting Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น •

  • @edgyman519
    @edgyman519 7 หลายเดือนก่อน +14

    Summary (if anyone has issue):
    - DataStore:GetAsync(plr.UserId, value) -- returns the value saved within that player's UserId, (will be nil if that player has no previous data saved) so you might want to save that particular value, as that player's leaderstats value or something
    - DataStore:SetAsync(plr.UserId, value) -- changes the value of the value saved within that player's UserId, so you might want to use the Players.PlayerRemoving event so that every time a player leaves, you can set their value as what they last had
    -pcall(function() -- so you basically wrap a function in a pcall to make that there is no data lost, while trying to send a request to roblox's DataStoreService

    • @AlvinBlox
      @AlvinBlox  7 หลายเดือนก่อน +6

      almost. pcall just prevents your script from throwing an error if there’s a problem with the request

    • @edgyman519
      @edgyman519 7 หลายเดือนก่อน +1

      ohh thanks for the heart and clearing that up for me!

    • @RedmanHarfire
      @RedmanHarfire 2 หลายเดือนก่อน

      i want to know something what is returning a value ????

    • @edgyman519
      @edgyman519 2 หลายเดือนก่อน

      @@RedmanHarfire Lets look at an example : Lets say we have a function that adds up numbers
      local function Add(num1, num2)
      Sum = num1 + num2
      return Sum
      end
      basically what you return, will become the value that you get from that function. In other words, if i was to write :
      local myNum = Add(2, 3)
      The value of Add(2, 3) would be 5, since the sum of the 2 numbers is returned. And therefore, myNum will he equal to 5.
      P.S : Hey man, data stores is a slightly more of an advanced topic, so I think it would be better for you if you watched alvin's beginner series videos on functions and returning values and all that, he explains it really well

    • @randomchannel2713
      @randomchannel2713 2 หลายเดือนก่อน

      Why is mine giving > {...} in the output...
      This is my script:
      local DataStoreService = game:GetService("DataStoreService")
      local DataStore = DataStoreService:GetDataStore("DataStore1")
      local Template = {Coins = 50}
      game.Players.PlayerRemoving:Connect(function(player)
      wait(5)
      pcall(function()
      DataStore:SetAsync(tostring(player.UserId), Template.Coins)
      end)
      end)
      game.Players.PlayerAdded:Connect(function(player)
      pcall(function()
      local data = DataStore:GetAsync(tostring(player.UserId))
      print(data)
      end)
      end)

  • @crooda3681
    @crooda3681 7 หลายเดือนก่อน +4

    It's been 10 years I think when I watched your old tutorials, you made me a good luau scripter thank you

  • @TDGrowing
    @TDGrowing 7 หลายเดือนก่อน +5

    Yes bro! Keep making these videos they help me so much. I get better and better every day because of you, like no joke they are so helpful. Please keep making more!

  • @blestoo5894
    @blestoo5894 7 หลายเดือนก่อน +29

    damn, your voice really changed since i saw you in 2016. Good work man! keep going.

    • @Sirbozo
      @Sirbozo 6 หลายเดือนก่อน

      yeee

    • @Short1794
      @Short1794 5 หลายเดือนก่อน +1

      who wouldve guessed lol

    • @gradientblob1014
      @gradientblob1014 5 หลายเดือนก่อน +2

      Everyone heere is simply talking about his voice, however, that is a fundementally normal part about being a human. growing up, is one of it. the fact that you are commenditing on this vide osi very rude and very not sigma and htsi ssomething that awthat shoulndt aef aw;elkj awlekfj;wlkej ;lawf jsig

    • @flame-ry7ps
      @flame-ry7ps 4 หลายเดือนก่อน

      @@gradientblob1014 tf ?

    • @edgyman519
      @edgyman519 2 หลายเดือนก่อน

      @@gradientblob1014 Testing if my reply goes through

  • @scriptexd
    @scriptexd 5 หลายเดือนก่อน +1

    Welcome back alvin i see that you cameback hopefully you will post more tutorials for us. Keep up with the good work 😀😀

  • @SpecialBloxIsAwesome
    @SpecialBloxIsAwesome 7 หลายเดือนก่อน +4

    Nice vid, had a problem with the data store stuffs... Thanks mate 👍

  • @xepicgamer3594
    @xepicgamer3594 7 หลายเดือนก่อน +1

    i was really confused about this, watched this now i don't think i'll ever face a problem when making datastores!

  • @kidnamedsolid3547
    @kidnamedsolid3547 7 หลายเดือนก่อน +1

    This is one of the best Data Store tutorials I've seen, keep it up.

  • @digery
    @digery 6 หลายเดือนก่อน

    Thank you so much for making this tutorial! I’m still learning and this helped me a lot.

  • @Niestrat99
    @Niestrat99 7 หลายเดือนก่อน +2

    Nicely explained as always, Alvin!

  • @jett27j30
    @jett27j30 2 หลายเดือนก่อน

    Always been my go to for scripting tutorials. I finally have grasped data stores with your tutorial after like 5 years of trying to learn scripting properly... only to learn about profile service and datastore2 😭Could you make a tutorial on that? Thanks for the amazing tutorials over the years by the way.

  • @tobyvr4658
    @tobyvr4658 7 หลายเดือนก่อน +1

    You are such a good scripter. Amazing video, keep up the good work

  • @theorderofthedarkoats3288
    @theorderofthedarkoats3288 6 หลายเดือนก่อน +1

    I'm confused about how this saves the data. Whenever the person leaves what saves the data to the datastore? I can't get mine to work, I'm just trying to save a leaderstat.

    • @dereckhernandezrivera3473
      @dereckhernandezrivera3473 5 หลายเดือนก่อน

      That's cause you have to use another script to call on the datastore

    • @theorderofthedarkoats3288
      @theorderofthedarkoats3288 5 หลายเดือนก่อน

      @@dereckhernandezrivera3473 scripting is so complicated 😭

    • @Nexed.1
      @Nexed.1 5 หลายเดือนก่อน

      ​@@theorderofthedarkoats3288fr

    • @CouldBeAnyone
      @CouldBeAnyone หลายเดือนก่อน

      It dint work because this video din't show us how to save the data when player leaves the game, might aswell look into other video that shows how to

  • @b4stardlol
    @b4stardlol 2 หลายเดือนก่อน

    hey! how i do a countdown with data store? like, when you leave and rejoin the timers dont reset?

  • @CountD3stroyer69
    @CountD3stroyer69 6 หลายเดือนก่อน

    but how can i like make that if u for example made a quest and earned coins it wills store and u can actually buy smth with the coins and they get minus but also the thing u bought will get stored

  • @0nebloone
    @0nebloone 4 หลายเดือนก่อน

    I am going to read what i have written logically if there is an error. Thanks AlvinBlox 👍

  • @ayyansinan_22
    @ayyansinan_22 7 หลายเดือนก่อน

    alvinblox I have a question can you make a tutorial on how you can make throwable knife like how you can throw a knife in murder mystery 2
    I tried doing it my self but every time I do there's something missing im not sure what it is that's thanks!

  • @iceiceburr
    @iceiceburr 6 หลายเดือนก่อน

    for some reason when i used this my data connected with someone elses but i joined on an alt and it wasnt connected for it

  • @superstorm4228
    @superstorm4228 5 หลายเดือนก่อน

    What's the point of making the players userID a string?

  • @sphilticL-7
    @sphilticL-7 21 ชั่วโมงที่ผ่านมา

    my brain expanded so much so fast it crushed up against the sides of my skull and I died
    good news is it worked when I followed this

  • @Briizardsx
    @Briizardsx 6 หลายเดือนก่อน +1

    Omg since when did we need to pay with USD to get plugins?? I can't afford Data store editor since USD is far superior than my currency 😭this is diabolical

    • @imthebestmayne122
      @imthebestmayne122 5 หลายเดือนก่อน +3

      It is extremely cringe. Though I am kind of glad in the long run, because I convinced myself that Moon Animator is NOT worth the $30 and instead learned Blender for animating.

  • @imthebestmayne122
    @imthebestmayne122 5 หลายเดือนก่อน

    Someone please correct me if I am wrong, but at 11:31 when he makes the deepcopy of the table, isn't he saving the non-copied table "Template" using SetAsync? Or is the premise that if you want to manipulate the data, it should be a deep-copied table?

    • @oleNikolic
      @oleNikolic 5 หลายเดือนก่อน

      Correct, Copying the template isnt done so he Could put it in the set async, it was for so you could use the data later.He Said hes doing it for safety and i will probably too. Now a nice way of using that deepcopied table would be by continuing the if Data == nil statement with else. That statement checks if its players First time joining the game, and if it is, it sets the players values to the values from any table you wrote(template),so if we Said else after it, it would basically mean, if they join for the second or higher time. And then you would write DataStore:SetAsync(Player.UserId,Template).Now you would also Need to have a way of making coins value or something else bigger trought the table. Also if u arleady know to make a leaderstats and some values in it for a game, i could teach you how to easily save it even after it has updated, you would Need to use game.Players.PlayerRemoving, which is a event which fires once the player leaves the game. So if u have any auestions ask😅Sorry for a long message

    • @imthebestmayne122
      @imthebestmayne122 5 หลายเดือนก่อน

      @@oleNikolic No, I actually know how to make a "DataStore". I am watching as many videos as I can to learn how to ACTUALLY make a DataStore, like from the "Implementing Player Data and Purchasing Systems" document on the Roblox API/Documentation. But unfortunately, there is no TH-cam video that goes THAT in-depth, which I guess is to be expected. So I just siphon through these beginner tutorials to try and learn new things.

    • @aminjaw
      @aminjaw 2 หลายเดือนก่อน

      @@oleNikolic hey when i tried to print my points, it times the value by 3 and if i try print my money, it just says "nil". btw i replicated the exact code just a few changed to the template but i know what im doing. any help?

  • @dereckhernandezrivera3473
    @dereckhernandezrivera3473 5 หลายเดือนก่อน

    Mind posting the completed script in des i had to delete it cause you switched up too fast, and it was to gumbled

  • @superstorm4228
    @superstorm4228 5 หลายเดือนก่อน

    Why do you need a deepcopy function, can't you just do "Data = template:Clone()"

    • @CouldBeAnyone
      @CouldBeAnyone หลายเดือนก่อน

      You cant clone a table, that only works for instances in workspace

  • @Chochie137
    @Chochie137 7 หลายเดือนก่อน

    do you just reupload a new script version on the same topic every year, i swear you’ve made like five other videos like this one

  • @ILEJOSTARGOJI713
    @ILEJOSTARGOJI713 7 หลายเดือนก่อน

    Can you make a tutorial on lowering the camera in first person mode when you do the crouch mechanic?

    • @plodethtrello9687
      @plodethtrello9687 3 หลายเดือนก่อน

      Make a part that is at the height of the players head when the crouching anim plays and then when u use the keybind for crouch tween between the main camera and the part you created for the camera.

    • @CouldBeAnyone
      @CouldBeAnyone หลายเดือนก่อน

      ​@@plodethtrello9687Works but changing camera offset is faster

  • @JackPlaysMinecraft575
    @JackPlaysMinecraft575 7 หลายเดือนก่อน

    This is Useful but it would be More Useful if there was a Simple vid on How to save The Player's Coins

  • @szymon8859
    @szymon8859 7 หลายเดือนก่อน

    Hey man, keep the good work, but i need your help, i don't know how to make a simulator, i have the map build but i don't know how to do breakables, orbs, buying areas. I only have a pet system from your tutorial that are realy good btw, if you can responde if you make this series it would be nice!

  • @kidnamedsolid3547
    @kidnamedsolid3547 7 หลายเดือนก่อน

    You should make a video explaining pcalls and xpcalls

  • @dizrods5609
    @dizrods5609 5 หลายเดือนก่อน

    does it actually work though?

  • @izkrucker
    @izkrucker 7 หลายเดือนก่อน

    Hey can we get the link to the plugin you used for the data viewing

    • @AlvinBlox
      @AlvinBlox  7 หลายเดือนก่อน

      Added to the description.

    • @izkrucker
      @izkrucker 7 หลายเดือนก่อน

      @@AlvinBlox thanks

  • @normalpup838
    @normalpup838 7 หลายเดือนก่อน

    Your voice really changed since i last watched your videos 5 years ago 😅

  • @VerifiedSkim
    @VerifiedSkim 7 หลายเดือนก่อน

    how did you make a deep copy

    • @AlvinBlox
      @AlvinBlox  7 หลายเดือนก่อน

      Added to description

    • @SQU1D_LORD
      @SQU1D_LORD หลายเดือนก่อน

      The link in the description does not help

  • @imnot4chriss
    @imnot4chriss 7 หลายเดือนก่อน

    accidentally clicked on the TH-cam notification, wsp

  • @saving_4_venti
    @saving_4_venti 7 หลายเดือนก่อน

    HII I USED TO WATCH YOU WHEN I WAS 9

  • @Gamergirl-Gaming-developer
    @Gamergirl-Gaming-developer 7 หลายเดือนก่อน

    Nice video Alvin

  • @AnycubicKobra2
    @AnycubicKobra2 5 หลายเดือนก่อน

    Nice video!

  • @Nae_Him
    @Nae_Him 7 หลายเดือนก่อน +1

    First

  • @marctheepicest2838
    @marctheepicest2838 7 หลายเดือนก่อน

    omgg ur back

  • @OfficialMichaelTheCollector
    @OfficialMichaelTheCollector 7 หลายเดือนก่อน

    Hey dude! Wanna collab?

    • @ItzRazeyy
      @ItzRazeyy 6 หลายเดือนก่อน +1

      why would someone with 485k subscribetswanna collab with some kid with 350 subscribers🤣🤣🤣🤣🤣

    • @OfficialMichaelTheCollector
      @OfficialMichaelTheCollector 6 หลายเดือนก่อน

      @@ItzRazeyyAY! WHAT DID YOU SAY???

  • @Air.shortss
    @Air.shortss 7 หลายเดือนก่อน

    I’m here

  • @TrapGTFins
    @TrapGTFins 7 หลายเดือนก่อน

    First comment 😊

  • @theam.9298
    @theam.9298 7 หลายเดือนก่อน

    this is very useful

  • @Nae_Him
    @Nae_Him 7 หลายเดือนก่อน

    First