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

My kick on click text button script isn't working?

Asked by 5 years ago

I am trying to make a script for a text button in a GUI that when pressed will kick the player from the game, this is what I have but it's not working.

local localplayer = game.Players.LocalPlayer

script.Parent.TextButton.MouseButton1Click:Connect(function(plr)
    plr:Kick(localplayer)
end)

1 answer

Log in to vote
4
Answered by 5 years ago
Edited 5 years ago

the parameters of the :Kick() function is the message of the kick, not the player. Also MouseButton1Click holds no parameters, so use the LocalPlayer which you have defined.

local localplayer = game.Players.LocalPlayer

script.Parent.TextButton.MouseButton1Click:Connect(function()
    localplayer:Kick("hacker") 
end)

:Kick()

Ad

Answer this question