Server script
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
Local Script
local frame = script.Parent.Frame local template = frame.Template local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables sendTables.OnClientEvent:Connect(function(plr, 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)
I don't know what the problem is. If you do give an answer, please describe why. Thank you!
The first thing I notice in the local script you have
sendTables.OnClientEvent:Connect(function(plr, players, non_players)
Since its in the local script you do not need to pass plr. Since the local script only knowns the client as the player
Only in server scripts when firing event you need to say which player, but the listener (the client) doesn't need to know since the server sent it directly to that client
Figured out that I just worded my variables wrong. Thank you guys for trying to help