local button = script.Parent
button.Activated:Connect(function()
game.Players.LocalPlayer:Kick("Cancled")
How do I make a script that kicks the player once they click a button on StarterGui?
3 answers
Alright. Let's assume that there is a button inside a ScreenGui inside the StarterGui. Inside the button is a LocalScript. This is the LocalScript's code:
local player = game.Players.LocalPlayer
local button = script.Parent
button.MouseButton1Click:Connect(function()
player:Kick('reason')
end)
Hope this helped!
umm game:Destroy()??
You should kick the player, not delete the game.
game.Players.LocalPlayer:Kick("Reason")
edit:
what is ".clicked" by the way? here fixed script:
local button = --You're button
button.Activated:Connect(function()
game.Players.LocalPlayer:Kick("Reason")
3 comments
How do I make it once they click the button?
Don't use "if". it's an event that fires when it's clicked you don't need an if statment
Don't use mousebuttonclick because it will not work on phones only on computers.
Hey, if you want to kick the person who clicked only, then you can use a local script and insert :
local button = game.StarterGui.ScreenGui.Button -- or wherever your button location is
button.MouseButton1Down:Connect(function()
game.Players.LocalPlayer:Kick("Reason")
end)
2 comments
This won't work. That's not how StarterGui works
i tried and it worked
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
MouseButton1Click is a ScriptSignal. Signal's can be connected to functions so when they're activated it runs the function. Use function Connect on MouseButton1Click. script.Parent.MouseButton1Click:Connect(function() game.Players.LocalPlayer:Kick("Reason"); end)
@pidgey I have heaard using activated is better? Is that true