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.
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.
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.
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:
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?
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)