New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I make a script that kicks the player once they click a button on StarterGui?

Asked by 3 months ago
Edited 3 months ago
local button = script.Parent
button.Activated:Connect(function()
game.Players.LocalPlayer:Kick("Cancled")
0
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 538 — 3mo
0
@pidgey I have heaard using activated is better? Is that true Freddan2006YT 88 — 3mo

3 answers

Log in to vote
0
Answered by
U_srname 137
3 months ago

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!

Ad
Log in to vote
0
Answered by 3 months ago
Edited 3 months ago

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")
0
How do I make it once they click the button? AwesomeMrBird -79 — 3mo
0
Don't use "if". it's an event that fires when it's clicked you don't need an if statment Freddan2006YT 88 — 3mo
0
Don't use mousebuttonclick because it will not work on phones only on computers. Freddan2006YT 88 — 3mo
Log in to vote
0
Answered by 3 months ago

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)

0
This won't work. That's not how StarterGui works U_srname 137 — 3mo
0
i tried and it worked shanelaw12 47 — 3mo

Answer this question