Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my script acting stupid saying player is not in the game when it is?

Asked by 5 years ago

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)

2
if Player is an object then use Player.Name I saw you using Player.UserId, tostringing the Player is like making a part a string... greatneil80 2647 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question