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

(SOLVED)How to do a script that will kick you with a message, when you clicked on a button?

Asked by 5 years ago
Edited 5 years ago

Like the title says,how to do a script that will kick you with a message, when you clicked on a button?

So when a local player/ player clicks on the button in a GUI, he gets kicked with a message on top, you know what I mean. The red message on top.

Thanks.

EDIT: Still have no luck, will this do?

button.onMouseButton1Click:connect(function()
game.Players.localplayer:Kick("You have been kicked for exploiting!")

Or did I mess up on something? Please tell me! Thanks!

EDIT: Accepted the working answer, thanks a lot all of you guys who helped me! ;) Made my day and it's just what I wanted! :D

4 answers

Log in to vote
0
Answered by
zValerian 108
5 years ago
Edited 5 years ago

Okay, I'll help you out. First, insert a remote event in replicated storage. Call it 'kicked'

Then, in the gui button that will kick them when they click, insert THIS LOCAL SCRIPT in it.

--local script in the button

script.Parent.MouseButton1Click:connect(function()

name = game.Players.LocalPlayer.Name

game.ReplicatedStorage.kicked:FireServer(name)

end)

THat will send the name to the server.

After that, make a SERVER SCRIPT in SERVERSCRIPTSERVICE

-- server script in serverscriptservice

game.ReplicatedStorage.kicked.OnServerEvent:Connect(function(player, name)

game.Players:FindFirstChild(name):Kick("put the message here")

end)

Good luck! If it doesn't work or you have questions, let me know!

0
You already have the player in the first OnServerEvent parameter. You can simplify line 5 just by doing 'player:Kick()'. You should never get the player using FindFirstChild ever. xPolarium 1388 — 5y
0
Works! Thanks, both of You! ;) CR_BEAST123 22 — 5y
Ad
Log in to vote
0
Answered by
oftenz 367 Moderation Voter
5 years ago

In order to do Client -> Server communication, use a remote event. I'd recommend reading up on the wiki exactly how to do this.

For the GUI simply use MouseButton1Click. Remember, this is not a request site. Learn your own material!

Log in to vote
0
Answered by 5 years ago

Clicked on a button? You mean a 2D UI or an actual 3D button?

You can make use of player:Kick(), while putting the message inside the bracket, for an example:

Suppose the player name is Builderman:

game.Players.Builderman:Kick(“You have been kicked for exploiting!)

For more information: visit here https://developer.roblox.com/api-reference/function/Player/Kick

0
No, I want when a player has clicked on a 2D button in my GUI, he get's kicked when he clicked that button, with a message. CR_BEAST123 22 — 5y
0
Then place a local script inside the button or player scripts, index the button, then call the event using ThatButton.MouseButton1Down:Connect(function() and then basically just do game.Players.LocalPlayer:Kick("Your message here") but instead of just doing the normal "end" do "end)". Like using those more however its basically the same idea.  Stephenthefox 94 — 5y
Log in to vote
0
Answered by 3 years ago

--put this into the button choosing local script! script.Parent.MouseButton1Click:connect(function() game.Players.LocalPlayer:Kick("Bye !") end)

Answer this question