(This is an example)
Let’s say I have a folder inside ServerStorage with parts that have properties, like this:
This player can spawn these parts via a GUI, which will clone the selected part and give it the saved properties.
How can I make a table of the properties to save so that each player have their saved values inside the part that they spawn when they join back in?
Is it possible to make something like this, for each player. Basically something that loops through all the parts in serverStorage, add thems in a table like that “as an index” and saves its properties:
local table = {
["Part1"] = {
points = 1;
active = false;
},
["Part2"] = {
points = 3;
active = false;
},
["Part3"] = {
points = 5;
active = true;
},
}
I’m kind of having a hard time explaining this lol, if you need clarification just ask.
Yes, when the player is added you can have a sort of cache for the data where you load it if it isnt there and if it is there then you set the cache to the new data and then you can retrieve the data throughout the game and then when the player leaves you can just save that data pretty easy by just indexing their userid with whereever you put the cache and then making sure to remove the player’s cache after you have saved their data
What do you mean make that table with that structure you already did it in your original post im confused what your asking, like how to make it so that it’s unique to the player?
local cache = {}
game.Players.PlayerAdded:Connect(function(player)
cache[player.UserId] = {
["Part1"] = {
points = 1;
active = false;
},
["Part2"] = {
points = 3;
active = false;
},
["Part3"] = {
points = 5;
active = true;
},
}
end)
I am asking how could I create a table for each player, that gets ever part in the ServerStorage folder and creates and index with their names and makes “arguments” in it, like this:
Yes on the line of this, but making a for loop that loops through the folder in ServerStorage and makes “indexes” with the items names in the ServerStorage folder