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

need help with script why will player:kick work in one but not the other?

Asked by 5 years ago

why will the player:kick work here?

1game.Players.PlayerAdded:connect(function(player)
2    player.Chatted:connect(function(msg)
3        if(msg == "I dont feel so good") then
4            player:kick ("Thanos Snapped")
5        end
6    end)
7end)

and not here

1function clicked()
2 player:kick ("oof")
3end
4script.Parent.MouseButton1Click:Connect(clicked)

pls help

1 answer

Log in to vote
0
Answered by 5 years ago

"player" is not defined. Put this in a localscript:

1local player = game.Players.LocalPlayer
2 
3function clicked()
4 player:kick ("oof")
5end
6script.Parent.MouseButton1Click:Connect(clicked)
Ad

Answer this question