Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is it possible to not spawn the player's character until they press a GUI button?

Asked by 8 years ago
Edited 8 years ago

I'm trying to make a menu. I want to prevent my character from spawning until I press "play". I know how to make the GUI, I just don't know how to control character spawning.

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

What you want to use is the CharacterAutoLoads property and LoadCharacter method. Setting the CharacterAutoLoads property of the Players object to false will make it so that the character won't load until the LoadCharacter method is called on the Player. What you could do is set the CharacterAutoLoads property to false, and when the GUI button is clicked, the player's character is loaded, like so:

local btn = script.Parent
local plr  = btn.Parent.Parent.Parent.Parent --If the button is the child of a frame, which is a child of screengui, which is in turn a child of the playergui, which is a child of the player, this would index the player.
game.Players.CharacterAutoLoads = false

function onClicked()
    plr:LoadCharacter()
end

btn.MouseButton1Click:connect(onClicked)

Keep in mind that you should only use CharacterAutoLoads and LoadCharacter in server scripts.

If this helped you out, remember to accept the answer, and don't be afraid to ask questions :D

1
What's wrong with using LoadCharacter in a local script? Perci1 4988 — 8y
0
It won't work well online unless it is a server script DepressionSensei 315 — 8y
Ad

Answer this question