First off, you shouldn't make this more complicated than it has to be.
Think of Tables exactly like folders - They store information. You can create a table, and whenever someone joins, add their name to the table. This prevents you from having to create ten folders!
For example:
local allPlayers = {}
game.Players.PlayerAdded:Connect(function(player)
if not allPlayers[player.Name] then
allPlayers[player.Name] = {}
end
end)
Now whenever you want to add information to the player, all you have to do is locate them in the table like so:
local allPlayers = {}
if allPlayers[Player.Name] then
allPlayers[Player.Name]["Value"] = true
allPlayers[Player.Name]["OtherValue"] = false
end
local allPlayers = {
"Player1" = {
"Value" = true;
"OtherValue" = false;
};
}
print( allPlayers[Player.Name]["Value"] )
Then, to remove a player when they leave the game, you can simply use PlayerRremoving to check when a player is leaving, and then remove them from the table like so:
local allPlayers = {}
game.Players.PlayerRemoving:Connect(function(player)
if allPlayers[player.Name] then
allPlayers[player.Name] = nil
end
end)
Now, this is most likely confusing at first, so here are some helpful links!
PlayerAdded, PlayerRemoving, Tables. Make sure to watch some videos for help!
If you need further help, let me know!
2 comments
In which way are you planning to add items to the folder?
cloning a viewmodel in replicated storage and putting it in the folders