I've recently been trying to make a script that stores a _G table variable for every player on the server. To do that i need to make sure that every _G instance has a different name so they don't interfere with eachother. So i came up with the excellent idea to use player ID's, But here's the problem. Is there any way to create a variable IN-GAME with a custom name?
Like maybe:
_G.["Table" .. 129265755] = {1,2,3}
But it doesn't work, Is there any other way i could do this?
I'm fairly new to "Advanced" coding so help would be greatly appreciated.
You can make a new index with the player's UserId like this:
_G.Players = {} game:GetService("Players").PlayerAdded:Connect(function(player) if not _G.Players[player.UserId] then _G.Players[player.UserId] = true end end) -- And if you want to delete it when they leave: game:GetService("Players").PlayerRemoving:Connect(function(player) if _G.Players[player.UserId] then _G.Players[player.UserId] = nil end end)
Hope this helps