The BEST way to save player game data in 2024: Roblox studio ADVANCED Scripting tutorial

In this roblox studio advanced scripting tutorial, I create a fully functional roblox studio player class that saves the players roblox studio game data into a roblox database using the roblox studio datastore service. Using roblox studio scripting using roblox lua, we first create a roblox studio script that sets up the player saving and loading. We then use roblox studio module scripts to and roblox functional programming to save the player data in roblox studio and create a player class using roblox studio OOP. This allows for you to store all of the players roblox game data in 1 roblox studio script. Hopefully this roblox studio scripting tutorial helped you create better roblox studio games and if it did leave a like and subscribe for more advanced roblox scripting tutorials.
The roblox studio scripts used in todays advanced roblox scripting tutorial:
The RBXL file that holds the scripts to today's video:
drive.google.com/file/d/1Xx1K...
Roblox advanced scripting tutorial episode 2 timestamps:
0:00 Introduction.
0:22 The final roblox scripts.
0:50 Roblox game scripts structure.
1:20 The server script.
1:27 The server script: Services.
2:10 The server script: Variables.
3:49 The server script: Events.
8:10 Saving the player data in roblox studio.
11:10 Using Functional programming to save player data.
12:43 Roblox studio player class using OOP.
22:10 Debugging our roblox scripts.
22:50 Final roblox studio test.
23:23 In the next roblox scripting video...
23:38 Conclusion.
Hopefully you enjoyed this roblox scripting tutorial: The BEST Way To SAVE Player Data In Roblox Studio. Roblox Studio ADVANCED Scripting Tutorial 2.

Пікірлер: 244

  • @DrDougan
    @DrDougan8 ай бұрын

    surely im not the only one, that thinks he sounds very similar to AlvinBlox

  • @kaleoscreations8069
    @kaleoscreations80697 ай бұрын

    Thank you Thank you Thank you!! This is my first exposure to class creation and multi-file script management in Roblox, I learned so much from this one video

  • @abdulrahman-zf2nn
    @abdulrahman-zf2nn7 ай бұрын

    This is the cleanest way to save data i have seen so far. You saved me so much time. Thanks

  • @user-mz7sh6mu3t
    @user-mz7sh6mu3t4 ай бұрын

    Maaan! I enjoyed this video 👏👏👏😍

  • @Karpizzzzzz
    @Karpizzzzzz6 ай бұрын

    watched this video while barely knowing tables, now im here learning about metatables 🔥

  • @vierdant
    @vierdant11 ай бұрын

    I'm so glad I stumbled upon your channel, this is actually pretty informative and your way of explaining is clear and direct to the point. Keep it up, spread the word and my man, you are going places.

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Appreciate the kind words, glad they could help in some way! Appreciate you watching

  • @MarzFromMars

    @MarzFromMars

    9 ай бұрын

    Same

  • @Erolsaurus
    @Erolsaurus10 ай бұрын

    Thanks for the tutorial! It was really helpful and I was surprised when it actually worked.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    No worries, glad it could help 😅👍👍

  • @seadrown6252
    @seadrown62528 ай бұрын

    I like this, but i think calling it a player class is slightly confusing, so I call it a profile instead. Really good video

  • @Gattostrano
    @Gattostrano10 ай бұрын

    Great video along with the explanation

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    Appreciate it, thanks for watching

  • @moravi2915
    @moravi29153 ай бұрын

    Great video! But I think that at the part of building the constructor function, it would be better to name the second parameter not with self, cause it could confuse people about the second self there. Also, you forgot to mention that it could be necessary to use Session Locking to prevent some scenarios ( and update async is better for this )

  • @VeryProPlayerYesSir1122
    @VeryProPlayerYesSir112210 ай бұрын

    very underrated youtuber. Keep up the good work

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Thanks, will do 👍👍

  • @gunipotys
    @gunipotys9 ай бұрын

    Nice video ! Also, why do you convert the data in Json ?

  • @vis7040
    @vis70403 ай бұрын

    u explain very well, thanks

  • @Fearlesscardinal
    @Fearlesscardinal11 сағат бұрын

    He open the light and explained the datastore very well

  • @Jscodin
    @JscodinАй бұрын

    very in-depth tut and good video - fyi anyone watching this in 2024, make sure you download the script in the description there are a few lines of code that have been added that weren't in the video, not sure what they're for but it makes it work lol though i am trying to see if this can be used to save checkpoints in an obby type game so when the player returns they show up on the same checkpoint, if anyone else is trying to do the same let me know if you figure it out before me lol

  • @mariomascena885
    @mariomascena8855 ай бұрын

    Thanks a lot for the video, it really helped me out with my game! If I may, can I ask you how to update the attributes of the player class (say "coins" and "level") with new attributes I added after the first login of my character? Because when I load my place all i see printed are the old attributes existing on the previous save, but the new ones are not indexed in the table I get, so my character doesn't have them initialized. I think new characters would have them all set on their first login, counting a total of 5 attributes instead of the 2 my current character has. Thanks a lot in advance and sorry for the silly question

  • @koainanis5840
    @koainanis58406 ай бұрын

    thx bro for this tutorial. well done. how can i show the coins in the leaderstats when i hit play?

  • @randallmason2042
    @randallmason20428 ай бұрын

    I really like this OOP way of handling player data. How would one implement this in a game with stats when you cant see the data and structures when testing? Would you write a loop to create player folder data or just do logging until you ironed out the code so no players see the data on the client side?

  • @kaleoscreations8069

    @kaleoscreations8069

    7 ай бұрын

    Log statement debugging is very powerful, so is breakpoint debugging. No need to reflect debug data in the UI

  • @MapleSyrup542
    @MapleSyrup5428 ай бұрын

    Btw I had a question remember when the roblox data loss in october 2020? is it hard to script recovery data? like if a player loses their data how to developers have backups and restore their data?

  • @alihandesu
    @alihandesu Жыл бұрын

    Keep making great content! 😊

  • @AshRBX_dev

    @AshRBX_dev

    Жыл бұрын

    Appreciate the kind words, will keep doing that!!

  • @Runtem

    @Runtem

    10 ай бұрын

    you are literally forcing the creator to do the way you like, that's not positive(please read this)

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    @@Runtem 🤣🤣

  • @gigione104
    @gigione10410 ай бұрын

    great video, if I had seen the code I might have been scared, but in half an hour I learned something very useful, thanks

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Appreciated, glad this video could help and thanks for watching!

  • @gigione104

    @gigione104

    10 ай бұрын

    @@AshRBX_dev I wanted to ask you if I could make a video in which I explained how to make a system to use that data somehow, for example by taking the value of 'coins' and creating an IntValue inside a folder within the Player, Thanks in advance even if you can not make a video.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    @@gigione104 I probably wont make a video expanding on this system. However, if you have discord join the AshRBX discord server which is linked in the description of all my recent videos. DM me on there and i will create a document that will show you how to do this for you with a RBXL file example.

  • @gigione104

    @gigione104

    10 ай бұрын

    @@AshRBX_dev ok

  • @Jaypiasco
    @Jaypiasco4 ай бұрын

    Can you show how this would be implemented if you wanted to do a 3 Slot Save system, where for each slot you can either Create a New Game or Load Game.

  • @ilikeminecraft4313

    @ilikeminecraft4313

    2 ай бұрын

    please help me do the same bc you prob figured it out by now, but do you also know how to save items

  • @system2150
    @system2150Ай бұрын

    Hey, great tutorial but I have a question! How would I modify the player's values from a local script? For example, if a player clicks their screen their coins would go up (Like in clicking simulators).

  • @inzanium

    @inzanium

    Ай бұрын

    use a remote event that fires a script on the server which updates the value?

  • @ArialSoftware
    @ArialSoftware11 ай бұрын

    Keep going!

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Will do! Next episode in a few days!

  • @Mario-xd9uk
    @Mario-xd9uk10 ай бұрын

    Really really good tutorial i just subscribed! Was looking for something like this 2 years ago and here it is! Did you learn all this by yourself or university/school?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Haha, sorry it took so long 🤣, this I learnt by myself, but the model used such as the OOP model was definitely a school thing.

  • @LeapInno
    @LeapInno5 ай бұрын

    Thank you. I don't understand datastores.

  • @elliebhoo
    @elliebhoo8 ай бұрын

    so i have a remote event to send a button click to the server script, and ive been putting all the code to change the datastore in the OnJoinTable false area, but every time a client clicks the image button it sets everybodys playerdata to be the same, how would i get the client to only modify their data?

  • @ThatGhostsHost
    @ThatGhostsHost11 ай бұрын

    That's a Dub. Good work man!

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Appreciate it! Glad to see you enjoyed 👍

  • @Jay-Crispy
    @Jay-Crispy6 ай бұрын

    im confused how would you access the stuff you made in constructor from say a gui shop button

  • @JDAWG04
    @JDAWG048 ай бұрын

    Thanks so much for this! Just a question though how can I connect to the PlayerClass from another script to set and update values and have those also save and load. For example I have a money spawner and when I walk over it the touched event should give me money but that script is in a completely different area

  • @sanic2765

    @sanic2765

    8 ай бұрын

    yea how would you do that?

  • @Zaldonorobloxtv

    @Zaldonorobloxtv

    7 ай бұрын

    Did you ever figure it out? I'm dealing with the same thing

  • @takinwhatsnotyours

    @takinwhatsnotyours

    Ай бұрын

    fire a remote

  • @Realadem_YT
    @Realadem_YT7 ай бұрын

    Very understandable, tho why is ur front text pixelated 🗿🗿🗿

  • @rayakzu
    @rayakzu4 ай бұрын

    Great informational video. Question though, why do you place a ";" after you define each variable?

  • @judemalcolm375

    @judemalcolm375

    4 ай бұрын

    its probs habit from other programming languages like c# or java, it doesnt do anything in lua as in you can have it if you want or not at all (it doesnt matter)

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    Apologies for the slow response. This is just a practice I’ve used coming from other languages, the syntax of lua allows for the use of ; so I use it it’s completely optional 👍

  • @user-np5cl1rp4e
    @user-np5cl1rp4e9 ай бұрын

    how do i make a reward module out of this? like add levels and add coins values etc

  • @cosmicdive
    @cosmicdive18 күн бұрын

    Can you make a cutscenes advanced scripting tutorial please?

  • @inzanium
    @inzaniumАй бұрын

    just wondering why do you get the player id by ps:GetUserIdFromNameAsync(Player.Name) instead of getting it via player.UserId?

  • @The_Kitty_Games
    @The_Kitty_Games7 ай бұрын

    Hey AshRBX can I use this script to save leaderstats? If so how do I?

  • @ThatOneDevil
    @ThatOneDevil5 ай бұрын

    I was wondering on how i could add data to the playerClass outside of the server script? and then make the server script save the changes data

  • @D4DDYD0NU7
    @D4DDYD0NU79 ай бұрын

    loved the video. i just have 1 question. how do i access the players coins from a local script

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    To get the class data in the client, you can set up a remote event system such as the one I go over in my server client communication video. To get this data you will have to call an event or function that returns the player Class to the client. However, I prefer it over other methods.

  • @notdimrb
    @notdimrb10 ай бұрын

    the data script is GREAT!! Just 1 question, is it better than datastore v2? The one that uses ordered data store, promises etc.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    It depends on your coding style imo, Data stores V2 is still an amazing tool and is used by so many people. I shared this one just based on how I would program outside of Roblox and is useful for me because I have external experience with other languages. So for me, I prefer this one 👍👍

  • @soma78
    @soma787 ай бұрын

    Very useful info (you've got a sub from me), but why is the audio so weird ? Like it's been stitched together from multiple recordings. Makes the whole thing a bit annoying and hard to follow. Uncanny valley or something, like when you're not sure your dialogue partner is entirely human or not. Why don't you make a scripted dialogue for the entire thing, once the video is in place and read it in one go ? Would me it so much more easy to follow along.

  • @tazkbar
    @tazkbar6 ай бұрын

    Your godsent for this video

  • @AlexisAutotte
    @AlexisAutotte4 ай бұрын

    How do you save data from a player who added ability like for exemple muscle mass on a gym simulator so when they get back in the game it retrieve the data from the progress the player made instead of getting the same 50 value again and again ? I followed your tutorial and applied the logic for my gym simulator but I can't seem to wrap my head about how to make sure it save the data each time I modify the value so for exemple I start at muscle mass 50 and when I bench I go to 51 but the problem is I get back in my game and everything is lost so the player has to restart and it's annoying

  • @yendodaso7329
    @yendodaso73299 ай бұрын

    under rated.

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    Appreciate it, thanks for watching the vid 👍

  • @TheGamepea
    @TheGamepea3 ай бұрын

    I loved your video and your tutorial thanks for everything but my output says "cant parse json" and cant load data please help me i am subscribed

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    This is usually a common issue that can be fixed by going to the game settings in the home tab, going to security, and enabling studio access to API services. Let me know if this helps 👍

  • @ariapanda

    @ariapanda

    3 ай бұрын

    tysm was having the same issue

  • @MysteryTheMysterious
    @MysteryTheMysterious6 ай бұрын

    Will it save game data too because I am adding building to my game so I want that to save

  • @rostats6451
    @rostats645110 ай бұрын

    I have a few questions on the datastore. Why does the onJoin table have result == nil or result == "null"? I never encountered 'null' before in lua, and the way you wrote it looks like a string so could you explain the difference between nil and "null"? Also, you get userid's from the players name, but wouldn't just doing player.UserId be more effective in case the player changes their username later on?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Yes, I’ve had a couple suggestions about player.UserId, this should be the way you do it, for some reason my brain didn’t think of it at the time I made the program 🤣. To answer your question on the null item, “null” is just a string that I used here to make sure that it hasn’t been saved as a string named “null”, this is for saving purposes. As an extension I will usually have it save “null” if the data needs to be reset or something similar. It’s mainly for debugging because you can just set it to nil here, so if you aren’t going use null anywhere, you can delete the or statement and keep it as onJoinTable[result == nil]

  • @rostats6451

    @rostats6451

    10 ай бұрын

    @@AshRBX_dev Okay, thank you for clearing that up, and also, you're the only channel I know that replies to videos made long times ago, so keep up the good work!

  • @il1ekp1e4

    @il1ekp1e4

    3 ай бұрын

    There are some use cases for null, for example, if you pass in a non table into JSONEncode if returns null instead of nil

  • @legendeca5535
    @legendeca55358 ай бұрын

    how would you access the instance of the player class we created originally outside the script that contains the player classes

  • @AshRBX_dev

    @AshRBX_dev

    8 ай бұрын

    One way to do this is instead of storing all of the instances in the table inside the Server script, store the table in a separate module script and require the module script when you need a player class

  • @UnfortunateKera
    @UnfortunateKera8 ай бұрын

    You're my third videos.. i cant figure why the previous 2 isnt working

  • @lucapagano3685
    @lucapagano36853 ай бұрын

    Nice tutorial! But how access the data now from another script, like displaying the coins, or add levels? should make the server script a module script?

  • @lucapagano3685

    @lucapagano3685

    3 ай бұрын

    i was reading other comments, will be good to make an external module script, with a function like "AddPlayerClass(playerId, playerClass)" and every time the onJoinTable add a playerClass to the playerClasses, added it to with the AddPlayerClass to another table in the module script, like a copy? would be the player class still synchronized and keep updating?

  • @lucapagano3685

    @lucapagano3685

    3 ай бұрын

    well if someones has an idea please share

  • @lucapagano3685

    @lucapagano3685

    3 ай бұрын

    check this code people, for adding more content to store in future game updates, change the first part of the playerClass script with this and add a copy of the ForLoops as child: local playerClass = {}; playerClass.__index = playerClass; function playerClass.new(player, oldSelf) repeat task.wait() until player.Character ~= nil --if oldSelf then return setmetatable(oldSelf,playerClass) end local self = {} self.name = player.Name self.character = player.Character self.coins = 0 self.progress = 0 if oldSelf then local function overrideKey(key,value) if oldSelf[key] then self[key] = oldSelf[key] end end require(script.ForLoops).pairsForLoop(overrideKey,self) end setmetatable(self,playerClass) return self end

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    Yes from using this many times after I created it it is more efficient to make the playerclasses table into a module script and access but you can also make the whole server script a module script and access the data from there 👍👍

  • @CAM-IS-NOT-REC
    @CAM-IS-NOT-REC8 ай бұрын

    how do i add or remove coins to the player trough a different script

  • @apolloed4879
    @apolloed48799 ай бұрын

    I'm pretty much a beginner in coding but I think I understand how your code works and it works in my game. I was wondering @AshRBX how you would actually use the saved data to create things such as a store where a gui button detects how much coins a player has, and takes away coins so a player can buy an item or something like that? I'm just stuck on the part of getting the loaded data into a script to create that what if statement so could you help me with that? I've seen multiple of your videos and they're very helpful for learning and work great!

  • @jassy553

    @jassy553

    7 ай бұрын

    to achieve this, simply make the player class a _G variable and have a server script check the value, or use a remote function

  • @kennyrozu6327
    @kennyrozu63279 ай бұрын

    Hello, this is a fantastic video! I am have an error with one line though. Line 39, in the playerJoined function, it keeps attempted to index nil with “name”. I suspect maybe it’s trying to get the name before the player has fully loaded, but I am unsure how to fix this. Any tips? Thanks again

  • @magpietaxi

    @magpietaxi

    8 ай бұрын

    Pro tip: learn basic programming before learning datastores.

  • @kennyrozu6327

    @kennyrozu6327

    8 ай бұрын

    @@magpietaxi I have learned basic programming, and have run into this problem before with other codes I’ve done. I was just wondering if you had a solution I haven’t been able to find yet.

  • @Strelkuh

    @Strelkuh

    6 ай бұрын

    @@magpietaxi Pro tip: if you want more friends try being friendly

  • @Jscodin

    @Jscodin

    Ай бұрын

    i think i had the same issue but i downloaded the script in the description and that solved it for me

  • @Phoenix-ox8cz
    @Phoenix-ox8cz9 ай бұрын

    great video! btw how would i get the saved playerclass table by their userId on a local script?

  • @Phoenix-ox8cz

    @Phoenix-ox8cz

    9 ай бұрын

    also how would i be able to clear a player's data?

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    To get the data in a local script, for this method you will have to use a remote event system to retrieve the data from the server. 👍

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    To clear the players data, all you need to do is set their table in the playerclasses table to a default player class, so just set the playerClasses[USERID] = playerClass.new(parameters) this will make a new default player class and when the player leaves this default one will save

  • @Phoenix-ox8cz

    @Phoenix-ox8cz

    9 ай бұрын

    @@AshRBX_dev thank you so much! so i can use your remote event system to retrieve data from the server?

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    Yes you can, the one from the server client video will help achieve your goal 👍

  • @erikas2272
    @erikas22729 ай бұрын

    How would you implement a custom table of players to start with the new player class data whether or not they already have saved data? In instance, you would have a table of exploiters users IDs and want to restart their progress?

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    You could have another table of user IDs underneath the playerClasses table that are hackers, and when the player joins you can check if the user’s ID is in the hacker table. If it is, then only call the function from the onJoinTable that sets all of the players data to the default (as if they’ve joined for the first time)

  • @GuiDuckz
    @GuiDuckzАй бұрын

    i started this video with a 1 minute 50 second unskippable ad.

  • @SassDuck
    @SassDuck5 ай бұрын

    Yo thnk you for the amazing video, but how do i save a folder instead of a value for example a player Inventory folder and its children.

  • @Jordan-xy9hs

    @Jordan-xy9hs

    Ай бұрын

    you probably know by now, but you need to save it as a table and load the children from replicatedstorage.

  • @SassDuck

    @SassDuck

    Ай бұрын

    @@Jordan-xy9hs yeah thank you I figured it out later on

  • @Jordan-xy9hs

    @Jordan-xy9hs

    Ай бұрын

    @@SassDuck 👍

  • @pontus3018
    @pontus30183 ай бұрын

    Does this work with leaderstats?

  • @speedyg2295
    @speedyg229511 ай бұрын

    Another great video that I am having a problem parsing data. But on another video that I don't know where I got. i remember putting in a version of the dataStore so that way you can update the stuff you save and then it will be version 0.0.2. Plus was a way to test brand new dataStore because I am not quite figuring out how to dump my current save that i think happened when I closed the game because it is saying player data was found. I will copy your scripts and see where I missed in the videos. But great stuff. On this topic say you made it to checkpoint4 in the game and on the player coming back to the game. The teleport section you have in PlayerClass would you have and conditional that if not new player be like self.Character.HumanoidRootPart.CFrame = loadedCFrame so that it teleports to that point of the saved game? of course would have to have saved that info but am I thinking in the right spot for that?

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Yes you can either add a conditional to the playerClass or use the server script in the video with the onJoinTable and put it in the place where we have created a playerClass for an existing user. You could then move them to the point stored in the datastore maybe it was stored in the playerclass as a checkpoint variable that equals a string with the checkpoint name.

  • @speedyg2295

    @speedyg2295

    11 ай бұрын

    @@AshRBX_dev Im stuck. Cannot seem to get passed an error Cannot Parse Json. and I think the problem is a save that happened because I cannot get it to clear that and start a new player. And I am trying to figure out where I can put the version like above but it's not working to make it think its a new player. Where do I dump the file that got saved so that I can run the script again as a brand new never been player so it creates the save all over.

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Which line states that you can’t parse JSON? Paste it in here and I can have a look

  • @Jscodin

    @Jscodin

    Ай бұрын

    @@speedyg2295 did you ever figure this out?

  • @speedyg2295

    @speedyg2295

    Ай бұрын

    @@Jscodin To be totally honest. I have not dug back into this since I had posted this. I think I propbably beat my head into the wall too much and wasn't getting any reply I had moved on. But I can see where I was trying to go. I wanted to place checkpoints if player makes it to this point then unlocks a different set of variables to happen from that point forward. And if they wanted to go back to a place to complete something not completed they could but could not move forward. But then I believe i got stuck on terrains because i wanted to transport to a different terrain all together for the checkpoint. Then life tended to get in the way as it does.

  • @CyTheo
    @CyTheo9 ай бұрын

    I woukd like to know to save item that players have on them so if they leave and join back they can join back and have the same items

  • @AshRBX_dev

    @AshRBX_dev

    8 ай бұрын

    You could use this to save the name of the item they have then give the item to them when they load in, this method will only save strings, bools, integers so using strings to store names of items would be a good use for it

  • @rostats6451
    @rostats645110 ай бұрын

    Hey, I had trouble implementing profileservice into my game, so I was wondering if according to the title, this method is actually better or equally as good as profileservice?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    The difference between profile service and this Class method is that profile service specialises in saving and loading data from data stores. This method however specialises in not only saving the player data but organising it so that you can use it more efficiently within your games for example you can obviously attach functions to the class and use inheritance and polymorphism within your classes which you cannot do with profile service. In the long run, Id use this method but profile service is another good tool if you are only saving and loading data with it.

  • @rostats6451

    @rostats6451

    10 ай бұрын

    @@AshRBX_dev okay thank you, the reason I don't use profileservice even though its a good tool was because it can't replicate the profile data to the clients, and sending remotes constantly for lets say a player clicking, would result in throttles.

  • @silentfilm1746

    @silentfilm1746

    10 ай бұрын

    ​@@AshRBX_devprofile service has much more features built in. Everything you said abt organizing player data is still possible with profile service. (Just a module handler for getting or setting data). It's good that u used OOP in your code, but It wouldn't help solve the main problem of 90% of data stores. I mean data loss, dupe, etc.

  • @silentfilm1746

    @silentfilm1746

    10 ай бұрын

    ​@@rostats6451it's possible with profile service. It's called ReplicaService. Made by same creator.

  • @silentfilm1746

    @silentfilm1746

    10 ай бұрын

    ​@@rostats6451and some additional info: profile service is about data. It's not about replicating it somewhere else. But u can use tons of network libraries or make your own to replicate data between client and server

  • @Gloozzy
    @GloozzyАй бұрын

    how would I make this compatable with leaderstats?

  • @exoticproto
    @exoticproto6 ай бұрын

    A bit of an issue I am having, I am trying to introduce a new value, however it will only ever work for first time joining players as the script returns the loaded table after checking if it exists. Any fix?

  • @ezilys8759

    @ezilys8759

    2 ай бұрын

    I'm having the same issue now . Did you figure it out?

  • @exoticproto

    @exoticproto

    2 ай бұрын

    nah, never did @@ezilys8759

  • @ezilys8759

    @ezilys8759

    2 ай бұрын

    ok I figure it now.

  • @qixxy3037

    @qixxy3037

    Ай бұрын

    how??@@ezilys8759

  • @magginator7834
    @magginator78347 ай бұрын

    Yo. I'm trying to connect a coin value from this script to the leaderstats. However, I see that in my output that my leaderstatsscript loads before the playerdata loads. Therefore when the leaderstatsscript runs, the script just assumes the playerclass is nil, therefore indexing my .coin with nil. I've tried to use a simple wait() function at the start of my leaderstatsscript, however this doesn't work, and will also not be a good idea... My function in the leaderstatsscript is ofcourse a PlayerAdded:Connect function. Do you have any idea how I can fix this problem :)

  • @magginator7834

    @magginator7834

    7 ай бұрын

    Nevermind, I still have this problem even though I'm making sure the playerdata has loaded before my leaderstatsscript is running.

  • @The_Kitty_Games

    @The_Kitty_Games

    7 ай бұрын

    @@magginator7834 Try adding waitforchild() also how do you connect leaderstats to the script?

  • @Ishowspeed556
    @Ishowspeed556Ай бұрын

    why was the result == "null" is it like 0?

  • @jamesmann260
    @jamesmann2602 ай бұрын

    Why use ps:GetUserIdFromNameAsync(player.Name) when player.UserId would give the same result? Did something change or am I just going crazy?

  • @AshRBX_dev

    @AshRBX_dev

    2 ай бұрын

    No you can use either for simplicity you can use .userId 👍

  • @dripmms5518
    @dripmms55189 ай бұрын

    here is the line I get my error: local playerClass = require(script.PlayerClass).new(plr, http:JSONDecode(result)); -- sets attributes to our new class, I can an errror saying: Can't parse JSON, I really liked this tutorial so I won't give up if there's any way to fix this please tell me because I finally found a data tore tutorial helpful and now I understand dataStores so I'll keep rewatching until I fully understand

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    One way to possibly fix this error is to make sure you have the data store API enabled, go into the settings in the Home tab, go to Security and enable the Roblox studio API option 👍 if this doesn’t work, join my discord server which is linked in more recent videos and message me there and I will take a closer look for you

  • @dripmms5518

    @dripmms5518

    9 ай бұрын

    @@AshRBX_dev ok thanks I'll try it out

  • @dripmms5518

    @dripmms5518

    9 ай бұрын

    @@AshRBX_dev Would I be able to use this for a level system with stats and everything and making races, for example human, elf, etc if so can you tell me how and which ways I can practise this method

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    Levels and stats can be saved in the player class, so you can 100% use it for that. For your races, you can use something called inheritance on your player class, you can create separate classes which are names as your races then you can use inheritance to link the race class to your player class. Then you can put different functions and variables in your race class which corresponds to that class of race 👍

  • @dripmms5518

    @dripmms5518

    9 ай бұрын

    @@AshRBX_dev ok thanks but how would I call inheritance and would I do it in the same script is inheritance __.index? and also would I be able to make fighting styles for example you can learn different fighting styles from an npc if you already have one you can't get another

  • @SEBTI
    @SEBTI9 ай бұрын

    just make leaderstats and make it invisable and bring data save leaderstats from toolbox and you are done you have best data saving in roblox

  • @SEBTI

    @SEBTI

    9 ай бұрын

    big games use this methood like criminality

  • @AshRBX_dev

    @AshRBX_dev

    9 ай бұрын

    This is probably one of the quickest ways to set up data storing, and if you like doing it this way then definitely do so. However I prefer this method because your programs will be more organised, you can apply aspects such as polymorphism, inheritance and encapsulation which you cannot do with leaderstats. Furthermore, you can attach different functions into your classes which allow for again more organised programs in large games.

  • @heli9499

    @heli9499

    9 ай бұрын

    @@AshRBX_devDoes datastore include tools and ui settings at the same time or is it limited to leaderstats only?

  • @YesKK978
    @YesKK97826 күн бұрын

    i have a question, how do i get the data from a user or user id IN the game or in studio

  • @AshRBX_dev

    @AshRBX_dev

    24 күн бұрын

    The best way you can do this is either using a bindable events from the server script or moving the player classes table into a module script

  • @Mr_lopz
    @Mr_lopz3 ай бұрын

    how can I access the values from a local script to display the „coins“ in a ui?

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    You can do this by firing a remote event from the server script and listen for the event call in your local script, you can send the data from the player class as an argument to the event and get it in the local script to then place onto your ui 👍

  • @Mr_lopz

    @Mr_lopz

    3 ай бұрын

    @@AshRBX_dev alright, thanks allot!

  • @deathanqel2077
    @deathanqel207711 ай бұрын

    Hello, I want to ask you a question. When I try to change the coins value with another script, I get an error attempt to index nil with 'value'. What should I do? Also thanks for the video

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    If you are trying to access the player class from another script, you need to reference the object that is in the player classes table. How are you trying to access the coins of the player from another script? Are you using events?

  • @deathanqel2077

    @deathanqel2077

    11 ай бұрын

    local PlayerClass = require(script.Parent.Server.PlayerClass) PlayerClass.coins.value += 100 I'm trying this but now I realized that I didn't write which player's coins value will change, how can I do that?

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    @@deathanqel2077 This definition of the playerClass is slightly incorrect. when you want to create a new player class for a player, you need to use the .new() function in order to create it. The example here showing how you create a new player class: local playerClass = require(script.PlayerClass).new(player); The player parameter here is just the player that you are creating the class for. Then you can do: playerClass.coins += 100 Hope this helps. If you need any more assistance let me know

  • @deathanqel2077

    @deathanqel2077

    11 ай бұрын

    sorry to bother but won't this code create a new player? I want to change the coins value of a registered player.Thank you for your time and patience with me.

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    Ah okay my bad for misunderstanding, if you have already created a new player class, it should be getting stored in your Playerclasses table that will be in the server. If this is the case, you can access a player class from the playerclasses table in the server class by using the player ID like it has been set up in the video. So if you’re in the server script, you can write: playerClass = playerClasses[USERID] where USERID is the players ID. This will get the playerClass linked to the player. Remember, when accessing a value from the player class self table, you need to just reference the variable you want to edit. So don’t use playerclass.coins.value += 100. You only need playerclass.coins += 100.

  • @setmini_gamingwitjcamera7673
    @setmini_gamingwitjcamera76734 ай бұрын

    Keep you please tell me how to make coins show up in guis?

  • @jstarandomdude

    @jstarandomdude

    3 ай бұрын

    local display = script.Parent.TextLabel local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild("leaderstats") display.Text = leaderstats.coins.Value

  • @yyhhttcccyyhhttccc6694
    @yyhhttcccyyhhttccc66943 ай бұрын

    how do i use this code where do i save the value to i cant read the coins values or level values how do i use this edit: i shouldent have gone to the advanced tutorial

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    The best practice for this is to save the playerClasses table as its own module script. This will then allow you to access the player info from anywhere on the server. To access data on the client, you will need to use remote events to request data from the client and return it back to them from the server

  • @Simo-dm1zd
    @Simo-dm1zd2 ай бұрын

    like this you never remove a player class inside the playerClasses table when he leave the game, is it good?

  • @AshRBX_dev

    @AshRBX_dev

    2 ай бұрын

    Yes this is true, as an extension of this if the server is open for more than 24 hours after the players leave you could remove the player from the PlayerClasses table as if your server stays open forever and you keep getting players you will get a memory leak. However keeping them all for a period of time after allows for data to be saved just to make sure the last player that leaves the server has their data saved as well

  • @Simo-dm1zd

    @Simo-dm1zd

    2 ай бұрын

    @@AshRBX_dev yea i removed the playerClass in the table after the player leave and his data has been saved, futhermore i added that every 5 minute it save data just to be more secure

  • @rievo5603
    @rievo560310 ай бұрын

    Great video! Question, why do we need to convert Lua table to JSON? Can't we just save it as it is? I tried saving it as Lua table and it worked fine.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    So you can save it without converting to JSON, but this can cause risk of data corruption inside the data store itself and I would recommend storing it as JSON, JSON converts the table into a string format and datastores only allow for you to store strings, numbers, booleans. This means that using JSON is highly effective and that’s why I used it in the tutorial. Hope this helps 👍👍

  • @4per8
    @4per84 ай бұрын

    for some reason when i try and print the playerClass it doesnt print anything

  • @4per8

    @4per8

    4 ай бұрын

    it turns out it was working just only in the server output and not in the ingame f9 menu

  • @abusekak1934
    @abusekak19345 ай бұрын

    why do we use semicolon ain this lua?, BUT TYSM NOW İ DONT A HAVE A PHOBİA OF DATASTORE edit: NVM WHY DOES İT NOT WORK WHEN İ PUT PLAYER.NAME BUT İT ALSO NOT WORK WHEN İ DONT PUT İT HELP GUYS WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

  • @sashapromin
    @sashapromin7 ай бұрын

    Hey Ash, i am curious about one thing. How its gonna save the new parameters of the module "PlayerClass"? So, for example, the player joined, script created its own new table with given attributes to save. Then he leaves. The new update releases, and it got new currency named "gems". Developer puts it in the constructor. The script sees that player already got result table and sets it as it was. New attributes will save for new players after the update, but not for players who played before. Is this works like that or i may be wrong?

  • @AshRBX_dev

    @AshRBX_dev

    7 ай бұрын

    I see your issue, and that is a valid point. What I would do is where we check the playerClass for an existing self table when we create the player class, instead of setting self to that previously saved self table, just loop through the self table inside the constructor that will set the values of the new self table to the values in the old one. This will then mean that any new variables you add after an update are carried over as well as your old values from the saved one. You can add checks to see if you've removed any variables too. So say the variable Coins was saved, and you removed coins in the update, you would check to see if coins exists in the new self table, and if so you can then go and replace the new coins value with the saved one. Hope this helps.

  • @sashapromin

    @sashapromin

    7 ай бұрын

    @@AshRBX_dev Okay, i was a bit confused and new to metatables, thanks for explaination!

  • @lucapagano3685

    @lucapagano3685

    3 ай бұрын

    check this code, for adding more content to store in future game updates, change the first part of the playerClass script with this and add a copy of the ForLoops as child: local playerClass = {}; playerClass.__index = playerClass; function playerClass.new(player, oldSelf) repeat task.wait() until player.Character ~= nil --if oldSelf then return setmetatable(oldSelf,playerClass) end local self = {} self.name = player.Name self.character = player.Character self.coins = 0 self.progress = 0 if oldSelf then local function overrideKey(key,value) if oldSelf[key] then self[key] = oldSelf[key] end end require(script.ForLoops).pairsForLoop(overrideKey,self) end setmetatable(self,playerClass) return self end

  • @sashapromin

    @sashapromin

    3 ай бұрын

    @@lucapagano3685 Interesting, thanks for help ;)

  • @Runtem
    @Runtem10 ай бұрын

    saving: learned.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Haha, glad this video can help 😅

  • @MbbScy

    @MbbScy

    10 ай бұрын

    ​@@AshRBX_devcan I save like character like "goku" if player owned the character?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    @@MbbScy yes, you could add self.unlockedCharacters = {} to your player Class and then add "goku" to your table

  • @Erolsaurus
    @Erolsaurus10 ай бұрын

    Sorry for the huge amount of comments, but I have a question: how do I add new stats to this? For example EXP.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    To add new stats, go into the playerClass module script, find the constructor and in that .new() function you will see the self.coins, stuff like this. To add EXP, just add self.exp = 0! This will be your default EXP value for when a user newly joins the game.

  • @Erolsaurus

    @Erolsaurus

    10 ай бұрын

    @@AshRBX_dev For some reason, the EXP variable doesn't show in the output.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    @@ErolsaurusIf you need, i have a discord server linked in my most recent videos, DM me from there and I can help in further detail on things that are not working as they should :)

  • @Erolsaurus

    @Erolsaurus

    10 ай бұрын

    @@AshRBX_dev Ok, thanks.

  • @Yazosu
    @Yazosu10 ай бұрын

    How can i get acces to this data from another scripts for example show number of coins in the UI

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    You would use a remote function from the client to request the players data. So on the client side you would call the remote function which could be called “getPlayerClass” and then in the server script you can listen for the event and return the class that belongs to the player using their player ID. This then gives you access to the coins value that’s in your playerClass and you can display this value on the players UI

  • @Yazosu

    @Yazosu

    10 ай бұрын

    @@AshRBX_dev thanks

  • @loukad.4812

    @loukad.4812

    7 ай бұрын

    @@AshRBX_dev bro I don't understand how to do that im stupid

  • @user-wv1du2bp3o
    @user-wv1du2bp3o6 ай бұрын

    how would you put the data onto the leaderstats?

  • @brain-in

    @brain-in

    Ай бұрын

    Add a folder called leaderstats and put an intValue in there Roblox will automatically make it as a leaderboard

  • @P3SKTheDev
    @P3SKTheDev9 ай бұрын

    It says "Can't Parse Into JSON"

  • @DaEvilDev

    @DaEvilDev

    9 ай бұрын

    Enable Allow HTTP Requests and Enable Studio Access to API Services in Game settings -> Security

  • @P3SKTheDev

    @P3SKTheDev

    9 ай бұрын

    i FOGOT TO TURN ON THE DATASAVE OPTION IN GAME SETS

  • @texark1700
    @texark17003 ай бұрын

    You seem to know a lot about java

  • @AshRBX_dev

    @AshRBX_dev

    3 ай бұрын

    Yes, I’ve done quite a lot of Java in the past.

  • @doughbnut
    @doughbnut11 ай бұрын

    im having a problem where it thinks im new every time i load the game

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    A couple of ways that the issue can be fixed: - Check your data store API is enabled, go to “game settings” in the HOME tab, then click on Security, then make sure Enable Studio Access to API Services is enabled. This will enable data storing. - if that doesn’t work, in the description there are paste bins to the main scripts used in the video, you can copy and paste the link into Google to find the code to each script and use that code to test if it works. - finally, if this doesn’t work, I will be creating a discord server soon where you can send me screenshots of the broken code and I will try to help debug for you 👍 Sorry for any inconvenience from the video, let me know if you have any more issues

  • @doughbnut

    @doughbnut

    11 ай бұрын

    @@AshRBX_dev the one with the self variables was deleted

  • @doughbnut

    @doughbnut

    11 ай бұрын

    i also have http and api services on

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    @@doughbnut pastebin.com/WiLVCjTG This is the link to the Player Class script that was missing

  • @doughbnut

    @doughbnut

    11 ай бұрын

    @@AshRBX_dev Copied all scripts and it didnt work :(

  • @doughbnut
    @doughbnut11 ай бұрын

    Can you make a model for this?

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    What do you refer to by model? Like an example scene or?

  • @doughbnut

    @doughbnut

    11 ай бұрын

    @@AshRBX_dev like an asset that we could download

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    If that’s preferred to links to script I’m totally happy to do that!

  • @doughbnut

    @doughbnut

    11 ай бұрын

    @@AshRBX_dev yep! thanks a lot

  • @AdimKivo
    @AdimKivoАй бұрын

    Why you used “;” and “,” near of end

  • @d4sty.

    @d4sty.

    Ай бұрын

    c/c++

  • @AdimKivo

    @AdimKivo

    Ай бұрын

    @@d4sty. thank you

  • @liam2795
    @liam279510 ай бұрын

    alivin blox?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    🤣🤣 not him

  • @johanistan
    @johanistan10 ай бұрын

    12:34

  • @Erolsaurus
    @Erolsaurus10 ай бұрын

    It says 'Can't parse JSON'

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Have you gone into the settings => Security => and turned on allow roblox enable studio access to API services? This might fix your issue. If not, let me know and if you want further help join my discord server and DM me and I’ll help further

  • @Erolsaurus

    @Erolsaurus

    10 ай бұрын

    @@AshRBX_dev Ah, thanks, that worked.

  • @Erolsaurus

    @Erolsaurus

    10 ай бұрын

    @@AshRBX_dev I also subscribed since your channel is very underrated.

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Glad that it worked and i appreciate the sub thanks for watching 👍👍👍

  • @notacreator2169
    @notacreator216911 ай бұрын

    im having an issue where it says can't parse JSON

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    In the description, there should be paste bins that contain the completed code. If you are having issues, compare your line to the line in the paste bin code. There are bug fixes at the end that I mention so if you haven’t watched them, I would recommend watching the bug fixes chapter in the video. I made a mistake with the JSON and then changed in the chapter let me know if you have any more issues 👍

  • @notacreator2169

    @notacreator2169

    11 ай бұрын

    @@AshRBX_dev Alright ty!

  • @notacreator2169

    @notacreator2169

    11 ай бұрын

    @@AshRBX_dev Really appreciated! I love the videos, they're helping me as a beginner scripter.

  • @notacreator2169

    @notacreator2169

    11 ай бұрын

    @@AshRBX_dev Also by the way, an error I am getting is Can't parse JSON

  • @AshRBX_dev

    @AshRBX_dev

    11 ай бұрын

    If you are still getting an error, if you send the line of code with the error I will debug it for you 👍

  • @sadge6430
    @sadge64306 ай бұрын

    faroud

  • @rumin_al642
    @rumin_al64219 күн бұрын

    he doesn't even know about player.UserId

  • @rein5614
    @rein5614Ай бұрын

    why it says Coins is not a valid member of Player "Players.Reinunstable"

  • @1k0de
    @1k0de10 ай бұрын

    Why do you use "PlayerService:GetUserIdFromNameAsync(Player.Name)", can't you just use "Player.UserId"?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    I've had many people comment this and yes, you're correct you can I think I just wasn't thinking when I wrote the program 🤣. I would 100% use that over my one.

  • @1k0de

    @1k0de

    10 ай бұрын

    @@AshRBX_dev Thanks for the reply! You also said in a real life scenario you would make a server class, could you explain that a bit more?

  • @AshRBX_dev

    @AshRBX_dev

    10 ай бұрын

    Yes of course, so what I meant by a server class is that it would be one class that holds all of the information and data for the server and each system such as the player saving system can relate back to that one player class. It’s a good way of having the server set up for easy access to different mechanisms in your game

  • @tiktok_AURAGT
    @tiktok_AURAGT3 ай бұрын

    can you give me the script pls

  • @Shadow-tu7yb
    @Shadow-tu7yb26 күн бұрын

    11:15