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

Unknown Global Player, Why is that?

Asked by 7 years ago
if player.Name == "Player 1" then
    player:Kick("This is a test")

end

1
It's because you never defined what player is. It's expecting player to be a variable defined in your script but it does not exist. What exactly are you trying to do? M39a9am3R 3210 — 7y

1 answer

Log in to vote
2
Answered by
itsJooJoo 195
7 years ago
Edited 7 years ago

Player is not in any hierarchy or even exists. Player is not identified. Here is an example of a script that identifies and kicks the player if it's Player 1:

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "Player 1" then
        player:Kick("This is a test")
    end
end)

Or if it's a LocalScript:

local player = game.Players.LocalPlayer

if player.Name == "Player 1" then
    player:Kick("This is a test")
end
Ad

Answer this question