local frame = script.Parent
local template = script.Parent:WaitForChild('Template')
local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables
local function newTemplate(playerName)
local newTemp = template:Clone()
newTemp.Name = playerName
newTemp.Parent = frame
end
sendTables.OnClientEvent:Connect(function(players, non_players)
for i, plr in pairs(players) do
if script.Parent:FindFirstChild(plr.Name) == nil then
newTemplate(plr.Name)
end
end
for i, plr in pairs(non_players) do
if script.Parent:FindFirstChild(plr.Name) ~= nil then
local destroyPlayer = script.Parent:FindFirstChild(plr.Name)
destroyPlayer:Destroy()
end
end
end)
Is there a problem in this script that can't be used in a local script? Thanks
