How do you use global codes, that show all the players?
COMMUNITY QUESTION
How do you use global, as in all servers connect?
1 answer
local ds = game:service"DataStoreService"
local list =ds:GetDataStore"PlayerList"
game.Players.PlayerAdded:connect(function(plr)
list:UpdateAsync("List", function(old) val = old or {} table.insert(val, plr.Name) return val end)
end)
game.Players.PlayerRemoving:connect(function(plr)
list:UpdateAsync("List", function(old)
for i, v in pairs(old) do
if v.Name == plr.Name then table.remove(old, i) end
end
return old
end)
end)
list:OnUpdate("List", function(data) for i, v in pairs(data) do print(v.Name) end end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
DataStore. I don't know much about it, but that's a start.