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

How To Make A Player Leave A Game On Click Of A Text Button?

Thanks for looking at my question. I'll dive into it.

What I Want To Happen

When a Player clicks a Text Button, I want them to leave the game. I have the code that I think will work, but probably not.

local Button = script.Parent.Quit
local HasPressed = false
function HasPressedQuit()
         if HasPressed == false then
          game.Players.LocalPlayer.Parent = nil
end

I Probably Know What Your Thinking...

This is wrong to the max, but if you guys could give me a link or something, that'll be great! Thanks!

GreekGodOfMLG

1 comment

0

You can't close out of their client, so kicking them is really the only option and then they still have to close out of roblox by themselves

3 answers

button.MouseButton1Click:connect(function()
	game.Players.LocalPlayer:Kick("Removed from server!")
end)

Make sure it's a local script and that you have declared "button" as the textbutton :3

5 comments

0

17:37:37.824 - Players.Player.PlayerGui.PauseMenu.MainFrame.PauseMenu:56: attempt to index local 'player' (a nil value)

0

woops NVM

0

Yeag, still get the same error 17:45:45.325 - Players.Player.PlayerGui.PauseMenu.MainFrame.PauseMenu:56: attempt to index local 'player' (a nil value)

0

Not my problem that's a fault on your side I'm not defining player, find out what's wrong.

0

MouseButton1Click does not return a Player value.

I remote-event is the best way using a fire-server command which instantly kicks a player, but requires scripting.

button.MouseButton1Click:connect(function(plr) plr:Kick("Player name") end)

3 comments

1

How about not copying my code? That would be great.

0

^ I didn't, It is on the Roblox Script Tutorials

0

How about not copying code?

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