Players Spawn - Main menu

Hello! I was wondering how I could “disable” players spawning into the map before they click the “PLAY” button on the MAIN MENU that I’m currently making. There’s a few “Spawners” around the map which are activated once the players join the game, how could I possibly disable them until the player clicks “PLAY” button?

My idea was putting them into a box in middle of nowhere and all the players that haven’t clicked the “PLAY” button yet, but I’m not sure how could I make that, if anyone can help me, I’d appreciate it.

3 Likes

You could make teams and make different spawners for each team (with the TeamColor property), or you could connect to the CharacterAdded event and then move the player if they haven’t clicked the play button.

1 Like

player:LoadCharacter i think might work

I was actually trying to do it without having to put “TEAMS”, I’ve seen a lot of games that has this feature and I was wondering how could I make it without teams.

And about the Moving players, they can simply reset and after pressing PLAY I wanted them to be in exact spot as one of the spawners, like they are spawning right now.

I’m sorry but I quite don’t understand what do you mean by that…

StartPlayer.CharacterAutoLoads = false

But this approach will stop the gui from cloning into StarterGui. A simple workaround (which is really good btw) is to move everything from StarterGui to a folder in Replicated Storage when the server starts and parent them to the player gui on the client. Now the pros with this system is that you don’t need to WaitForChild for anything as it is all directly available (and if you are skeptical just do WaitForChild for direct children only)

Then set up your main menu logic as usual but when the play button is clicked, fire off a RE to the server and the server then loads the character for the said player:

SpawnPlayer.OnServerEvent:Connect(function(player)
    player:LoadCharacter() -- Yields btw
end)
2 Likes

That’s why you connect to .CharacterAdded. It will keep moving them back if they respawn until they click “Play”.

local Players = game:GetService("Players")

local RESPAWN_DELAY = 5

Players.CharacterAutoLoads = false

local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		local humanoid = character:WaitForChild("Humanoid")

		local function onDied()
			task.wait(RESPAWN_DELAY)
			player:LoadCharacter()
		end

		humanoid.Died:Connect(onDied)
	end

	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

you can put player:LoadCharacter in this code to manually make the character spawn in

Disabling ‘CharacterAutoLoads’ seems a good idea, but where will the players be when this is enabled? Will they be able to play the game? Or they just don’t exists?

No, their character won’t exist, look at the post I sent once again cuz I added some edits.

I found a script you can add to yours:

in “StarterCharacterScripts” Add a “LocalScript” then paste this:

script.Parent.Parent = game.ReplicatedStorage

with your spawning script add this code (make sure your script is a “LocalScript” :

script.Parent.MouseButton1Down:Connect(function()
	local player = game.Players.LocalPlayer -- looks for player
	
	local char = player.Character -- looks for the players character
	
	char.Parent = game.Workspace -- put the players character into game.workspace to make the character playable!
	
end)
2 Likes