Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

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

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.