Hello, so.. i use global variables for all the player's data, with a dictionary:
_G.data = {}
game.Players.PlayerAdded:Connect(function(player)
_G.data[player.userId] = UserData:GetAsync(tostring(player.userId)) or
{
money = 0, lvl = 0, xp = 0, stage = 1
}
end)
everything is in this global variable, but i want to know if it's good to use or sometime it'll break. and if it does break sometimes, should i use Bindable Events to call the data?
something like
in main:
data = {}
game.Players.PlayerAdded:Connect(function(player)]
data[player.userId] = UserData:GetAsync(tostring(player.userId)) or
{
money = 0, lvl = 0, xp = 0, stage = 1
}
end)
events:WaitForChild("getData").OnServerInvoke = function(player)
return data[player.userId]
end
in some script:
local data = events:WaitForChild("getData").InvokeServer(player)
...

1 comment
Thanks, that helped