Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do you use global, as in all servers connect?

Asked by 10 years ago

How do you use global codes, that show all the players?

0
DataStore. I don't know much about it, but that's a start. Maxomega3 106 — 10y

1 answer

Log in to vote
0
Answered by
wazap 100
10 years ago
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)

Ad

Answer this question