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

Main Title Gui Help?

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.

2 answers

✓ Accepted answer

Here is a script I made in another post it will stop a character from loading:-

local respawnDelay = 15 -- delay time

game.Players.CharacterAutoLoads = false --Stop character auto load

game.Players.PlayerAdded:connect(function(player) -- new player in the game added

    player.CharacterAdded:connect(function(character) -- character sporns/ re-sporns

        local humanoid = character:FindFirstChild("Humanoid")  -- find humanoid in character

        if humanoid then -- humanoid is found

            humanoid.Died:connect(function() -- add a humanoid died event

                humanoid.Parent:Destroy() -- cleanup character or it will stay in the game

                wait(respawnDelay) -- wait for specified time
                player:LoadCharacter() -- load new character

            end)
        end     

    end)

    wait(respawnDelay) -- delay for new player when they join the game
    player:LoadCharacter() -- load character
end)

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:-

script.Parent.MouseButton1Click:connect(function ()
	game.Workspace.disconnectPlayer:FireServer() --The location of the remove function
end)

In the server script:-

local event = Instance.new("RemoteEvent") 
event.Parent = game.Workspace -- This needs to be somewhere the player can access
event.Name = "disconnectPlayer" 
--You can create the object but decided to create on in this script


event.OnServerEvent:connect(function(plr,msg)  --Player name is passed to the script
    local gplr = game.Players:FindFirstChild(plr.Name) --finds the player in Players
	gplr:Kick()  --kicks the user 
	
end)

6 comments

0

But do you know how to create an exit script? Thank you for the spawn script but the exit script is the most important. :)

0

You can use the kick event for the player http://wiki.roblox.com/index.php?title=API:Class/Player/Kick. This needs to be on the server and you will need to setup a remote event from the client to the server. http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial

0

I carnt make the the script today but i can make one tomurrow.

0

Please do. Thank you very much.

0

I have added the script. Hope this helps

0

Thank you so much! ????

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