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
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!
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:
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)