I have this GUI that has a Quit button on it, I couldn't find anyone having the script. I'm looking for a script that allows the GUI to close Roblox when you click it.
There is no way to close RobloxPlayerBeta.exe using scripts from your game. But you can kick the player out of the server.
Here's a demonstration of how to do it:
local PLAYER = game.Players:FindFirstChild("PLAYERNAMEHERE") local BUTTON = script.Parent:FindFirstChild("BUTTON") BUTTON.MouseButton1Down:Connect(function() PLAYER:Kick("You have kicked yourself, congratulations.") end)
The PLAYER:Kick() function can be called from both ServerScript and LocalScript. Just remember that you can only kick the LocalPlayer from a LocalScript. The argument inside :Kick() is the reason. It can be empty as it's defaulted to nil.
It's quite simple, really. Let me explain.
Lua is not powerful enough to interfere with the UIs created by Visual Basic and/or C. Although Lua does have a C API outside of Roblox, it can't close that program. Plus, all Lua scripts use UIs written in C, which make things a lot harder than they should.
Roblox uses C for its UI, so Lua can't interfere with it. That being said, you can't close the executable with a Lua script and the only way to close it is by pressing the red button at the top of the UI window. That's all I have to say.