Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

So I need help with on click of a text button it kicks player can you help?

I need the player to be kicked after they click the Textbutton which is named leave mine sucks so please help me

local function onMouseClick(player)
  print("you have been kicked")
  player:Kick 
end)
clickDetector.MouseClick:connect(onMouseClick)

that is my mess up.

1 comment

0

you're forgetting the brackets, player:Kick(), also thats not a textbutton, thats for a clickdetector

2 answers

You forget to add () at line 3 after :Kick

local function onMouseClick(player)
  print("you have been kicked")
  player:Kick("You have been kicked... for fun") -- You can tell them the reason why they have been kicked by putting a string inside ()
end)
clickDetector.MouseClick:connect(onMouseClick)

Hope that helped

2 comments

0

you should add a player check, as i assume this is what he wants

0

aiming4u why would we need a playercheck if hes trying to click the player who pressed the button?

You forgot to add () after the kick and you printed before the player gets kicked Put a local script in the textbutton

The code in the local script should be:

local PlrToKick = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
PlrToKick:Kick("you have been kicked.. for fun")
print(PlrToKick.Name.." has been kicked from the game.")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.