Yeah, play test, you know just hit play
13:55:41.736 player has data - Server - Script:16
13:55:41.736 {} - Server - Script:17
13:56:04.440 Disconnect from ::ffff:127.0.0.1|53420 - Studio
13:56:04.445 {} - Server
13:56:05.143 08DB29CEB8190366.0000000008.08DB29D0F6ADB405.01 - Server
In this exaple Im manually saving a string value from server side before leaving, so datastore has something to save in:
Its starting as a new player, and rejoin to get the tool
m
Oh get it, its because you are not saving anything.
Look, with the approach you are using you are handling 2 folders, which works for different stuff
Inventory folder (inside Player instance) Its holding StringValues, that will be used by the script to save them into the Datastore, its mere names, thats all, the names of the tools to save.
Then the Backpack folder, in which the Tools that a player owns are placed. When player leaves its NOT saving this folder, this is just for the player to carry the tools, not for being saved.
So the only thing being saved its the strings in the Inventory folder. So datastore only has the names of the tools.
When player joins, it will check those names and find the proper tools in ServerStorage, to clone them and place them in the Backpack of the player
Are you serious? It was that simple, Goddamn. Iām really sorry for the trouble, Sometimes I donāt analyze scripts properly
Yeah that was the last issue, along with the ones we fixed along the topic, like no having a folder, not getting the table correctly when leaving, not handling the join datastore check properly with pcall() etc.
Oh, Alright that was a better explaination. I couldnāt understand earlier I literally only have 14 hours all time on roblox studio and donāt really understand more advanced things.
I just thought pcall was an error thing and it would work the same without it. Now i kinda understand how useful it is. Thanks for simplifying it for me.
The pcall() its extremely useful yup, when running functions that you cant be sure will not error, otherwise script will stop totally, imagine having a script that handles a timer for a round, and that timer breaks due to an error, timer would be frozen and game will never work (it did happen to meā¦ xD)
Or when using many roblox APIs, which are not guarantee it will return data or not fail. Like the Datastore, which can fail easily, or Teleportation, AwardBadge and many many others.
So pcall() will help to know when API failed, and you need to do retries until getting a proper return.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.