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?

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if(msg == "I dont feel so good") then
            player:kick ("Thanos Snapped")
        end
    end)
end)

and not here

function clicked()
 player:kick ("oof")
end
script.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:

local player = game.Players.LocalPlayer

function clicked()
 player:kick ("oof")
end
script.Parent.MouseButton1Click:Connect(clicked)
Ad

Answer this question