So this function is run when a player leaves
function module.RemoveTable(Player) wait(30) if game.Players:FindFirstChild(tostring(Player)) then print(Player,' Is In The') else Mod[Player.UserId] = nil print('Was Destroyed') end end
game.Players.PlayerRemoving:Connect(function(Player)
module.RemoveTable(Player)
but it keeps destroying the table even with the player in the game which means the game thinks hes not in the game
end)
For starters, it's nothing to do with the script. Scripts have a reason for throwing an error. Right now, you're trying to cast a player to a string. Since that is not possible, the script will throw an error. If you wanted to tostring the player name, you would do this:
tostring(plr.Name)
if you wanted to tostring the id you would do this:
tostring(plr.UserId)
only things that can be cast are strings, ints, etc.