Apparently to add and remove players off the xf list of mine, i need to call the numbers but I don't know that, but by doing removing the table if the name of the value is caught. the error log says number expected not tostring. What can I do? Thanks
local xf = { "...", } for i, v in pairs(game:GetService("Players"):GetPlayers()) do if v ~= game:GetService("Players").LocalPlayer then table.insert(xf, tostring(v.DisplayName)) end end game.Players.PlayerAdded:Connect(function(v) if not table.find(xf, tostring(v.DisplayName)) then table.insert(xf, tostring(v.DisplayName)) end end) game.Players.PlayerRemoving:Connect(function(v) if table.find(xf, tostring(v.DisplayName)) then table.remove(xf, tostring(v.DisplayName)) end end)[](http://)
You can try to make it a dictionary instead if it does not conflict with your code.
local Players = game:GetService('Players') local dictionary = {} for _, player in pairs(Players:GetPlayers()) do if player ~= Players.LocalPlayer then dictionary[player.Name] = true end end Players.PlayerAdded:Connect(function(player) dictionary[player.Name] = true end) Players.PlayerRemoving:Connect(function(player) dictionary[player.Name] = nil end)
OR
local Players = game:GetService('Players') local array = {} for _, player in pairs(Players:GetPlayers()) do if player ~= Players.LocalPlayer then table.insert(array, player.Name) end end Players.PlayerAdded:Connect(function(player) table.insert(array, player.Name) end) Players.PlayerRemoving:Connect(function(player) table.remove(array, table.find(array, player.Name)) end)