So I have a blank LocalScript in the StarterGui.
I have
script.Parent.MouseButton1Click:connect(function() LocalPlayer:Kick() end)
inside of a GUI button.
So why is it that when I click the GUI button I don't get kicked?
Azarth (Another guy who answered this question), seems to know more than me. Here's the script... Remember, it needs to be in a normal script...
script.Parent.MouseButton1Click:connect(function(p) --Calls the function and declares the player as "p" p:Kick() --Obvious... end)--Ends the function
Hmm, try this;
script.Parent.MouseButton1Click:connect(function() --If the Scripts Parent is in the TextButton, then this will work if game:FindService("Players")and game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")then --If script finds service Players within Game, LocalPlayer exists (As a just incase :P), LocalPlayer's Character exists, and LocalPlayer's Character's Humanoid exists then game.Players.LocalPlayer:Kick() --Kicks LocalPlayer end end) --All the ends for the script
I hope this helped!
You can't use the Kick() method in a LocalScript, use a RemoteFunction to communicate with a script to do it.