Hi! I’ve being working on this for a few days now and I still can’t figure it out.
-- Server script in ServerScriptService
local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables
local module = require(game.ServerScriptService.module)
local players = {}
local non_players = {}
while true do
for i, plr in pairs(game.Players:GetPlayers()) do
if plr.TeamName.Value == 'Player' and plr.ListedOnHealth.Value == false then
if module.checkForTable(non_players, plr.Name) then
table.remove(non_players, table.find(non_players, plr.Name))
end
table.insert(players, 1, plr.Name)
plr.ListedOnHealth.Value = true
elseif plr.TeamName.Value ~= 'Player' and plr.ListedOnHealth.Value == true then
if module.checkForTable(players, plr.Name) then
table.remove(players, table.find(players, plr.Name))
end
table.insert(non_players, 1, plr.Name)
end
end
print(players)
print(non_players)
sendTables:FireAllClients(players, non_players)
wait(0.1)
end
This is the local script
--Local script in a starterGui
local frame = script.Parent.Frame
local template = frame.Template
local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables
sendTables.OnClientEvent:Connect(function(players, non_players)
if players and non_players then
for i, plr in pairs(players) do
print('going thru')
if script.Parent:FindFirstChild(plr.Name) == nil then
local newTemp = template:Clone()
newTemp.Name = plr.Name
newTemp.Parent = frame
end
end
for i, plr in pairs(non_players) do
print('going thru2')
if script.Parent:FindFirstChild(plr.Name) ~= nil then
local destroyPlayer = script.Parent:FindFirstChild(plr.Name)
destroyPlayer:Destroy()
end
end
end
end)
Any help would be appreciated. Thank you!