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?
1 | button.onMouseButton 1 Click:connect( function () |
2 | 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
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.
1 | --local script in the button |
2 |
3 | script.Parent.MouseButton 1 Click:connect( function () |
4 |
5 | name = game.Players.LocalPlayer.Name |
6 |
7 | game.ReplicatedStorage.kicked:FireServer(name) |
8 |
9 | end ) |
THat will send the name to the server.
After that, make a SERVER SCRIPT in SERVERSCRIPTSERVICE
1 | -- server script in serverscriptservice |
2 |
3 | game.ReplicatedStorage.kicked.OnServerEvent:Connect( function (player, name) |
4 |
5 | game.Players:FindFirstChild(name):Kick( "put the message here" ) |
6 |
7 | end ) |
Good luck! If it doesn't work or you have questions, let me know!
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!
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:
1 | game.Players.Builderman:Kick(“You have been kicked for exploiting!) |
For more information: visit here https://developer.roblox.com/api-reference/function/Player/Kick
--put this into the button choosing local script! script.Parent.MouseButton1Click:connect(function() game.Players.LocalPlayer:Kick("Bye !") end)