I'm trying to make a starting guis where theres multiple buttons consisting of "Play, Options, Extra, and Exit" But i can't come up with a script to make it all function. I want to disable character spawning until he/she presses play and chooses his/her job, and I'm trying to make the game exit when ever i press the exit button. Please help me I've been looking hard for a way to do this.
Here is a script I made in another post it will stop a character from loading:-
01 | local respawnDelay = 15 -- delay time |
02 |
03 | game.Players.CharacterAutoLoads = false --Stop character auto load |
04 |
05 | game.Players.PlayerAdded:connect( function (player) -- new player in the game added |
06 |
07 | player.CharacterAdded:connect( function (character) -- character sporns/ re-sporns |
08 |
09 | local humanoid = character:FindFirstChild( "Humanoid" ) -- find humanoid in character |
10 |
11 | if humanoid then -- humanoid is found |
12 |
13 | humanoid.Died:connect( function () -- add a humanoid died event |
14 |
15 | humanoid.Parent:Destroy() -- cleanup character or it will stay in the game |
To answer your other question you may need to look into a loading Gui like my place. My Place
Edit disconnects player from gui:-
Localscript in the GUI:-
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | game.Workspace.disconnectPlayer:FireServer() --The location of the remove function |
3 | end ) |
In the server script:-
01 | local event = Instance.new( "RemoteEvent" ) |
02 | event.Parent = game.Workspace -- This needs to be somewhere the player can access |
03 | event.Name = "disconnectPlayer" |
04 | --You can create the object but decided to create on in this script |
05 |
06 |
07 | event.OnServerEvent:connect( function (plr,msg) --Player name is passed to the script |
08 | local gplr = game.Players:FindFirstChild(plr.Name) --finds the player in Players |
09 | gplr:Kick() --kicks the user |
10 |
11 | end ) |
This tutorial may be off some use to you m8: http://youtu.be/j2NkgD4lqeU