Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

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 YellowoTide 1992 — 9y

3 answers

Log in to vote
0
Answered by
Ryzox 220 Moderation Voter
9 years ago
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

0
17:37:37.824 - Players.Player.PlayerGui.PauseMenu.MainFrame.PauseMenu:56: attempt to index local 'player' (a nil value) GreekGodOfMLG 244 — 9y
0
woops NVM GreekGodOfMLG 244 — 9y
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) GreekGodOfMLG 244 — 9y
0
Not my problem that's a fault on your side I'm not defining player, find out what's wrong. Ryzox 220 — 9y
0
MouseButton1Click does not return a Player value. M39a9am3R 3210 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago

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

Log in to vote
-7
Answered by 9 years ago

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

1
How about not copying my code? That would be great. Ryzox 220 — 9y
0
^ I didn't, It is on the Roblox Script Tutorials Scripts1 -2 — 9y
0
How about not copying code? fireboltofdeath 635 — 9y

Answer this question