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

How do i make a play button without just moving a gui?

I am trying to make a play button but when i research on how to do it they instruct you to either disable a GUI, destroy, edit transparency, etc. but I am trying to make a play button that spawns your character in. any help?

1 answer

✓ Accepted answer

Ok so you want a button, that when clicked, will spawn the players character. Theres a few ways to do this, but I'll go through the most reliable.

As roblox works, a players character needs to have spawned in to display a GUI so you cannot have a play button that does the spawning. Instead we are going to make a button that will respawn the charater, after setting the players respawn location.

The things you will need for this are: Two scripts (Local for the GUI and Server for the character respawn), A remote (To link the scripts), A spawn location. A ready made GUI and the position you want the player to spawn at.

To make this easier, turn the ResetOnSpawn property of the GUI to off.

Now onto the scripts themselfs, inside the local script you want to use this variable (I named the Remote SpawnPlayer to make it easy):

local Remote = game.ReplicatedStorage.SpawnPlayer, `

For the server sided part you only need two variables:

local Remote = game.ReplicatedStorage.SpawnPlayer and local EndLocation = Vector3.new(0,5,10)

When it comes to the actual main scripting parts, its pretty easy, in the local script you want to use:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
	
	Remote:FireServer()
end)

In the server script we will run the function for the :FireServer():

local function SpawnPlr(Plr)
	Plr.RespawnLocation = EndLocation
	wait()
	Plr:LoadCharacter()
end

Remote.OnServerEvent:Connect(SpawnPlr)

In the end your scripts should look similar to this:

--Local script--

local Remote = game.ReplicatedStorage.SpawnPlayer

script.Parent.MouseButton1Click:Connect(function()
	wait()
	
	Remote:FireServer()
end)
--Server script--
local Remote = game.ReplicatedStorage.SpawnPlayer
local EndLocation = Vector3.new(0,5,10)

local function SpawnPlr(Plr)
	Plr.RespawnLocation = EndLocation
	wait()
	Plr:LoadCharacter()
end

Remote.OnServerEvent:Connect(SpawnPlr)

This has been tested and works.

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