Could I make a button that spawns the character when you press the button?

Hey, I’m wondering if I could make a deploy menu for a FPS game. But, I wanna make it where when the GUI is visible the character isn’t spawned, and once you press a button you spawn in and the GUI closes. Is there a way to do this?

(I know there’s a characterautoloads property in Players, but I don’t know how to use it, and I’m not sure it’s related to this)

7 Likes

Turn off CharacterAutoLoads, and when you load the character, use

player:LoadCharacter()--on server
2 Likes

Nothing happens. I used

script.Parent.MouseButton1Click:Connect(function()

player:LoadCharacter()

end)
2 Likes

it should be

script.Parent.MouseButton1Click:Connect(function() 
    game.ReplicatedStorage.TeamChoose:FireServer(team)
end)

and then on server

game.ReplicatedStorage.TeamChoose.OnServerEvent:Connect(player,team)
    player:LoadCharacter()
    --otherstuff
end)
2 Likes

or if the script is on server then just load directly

2 Likes

LoadCharacter info:

2 Likes

I’ll just use that info… Because I have no idea what this stuff means lol (Update: that had nothing either)

3 Likes

Could you show us what appears in the output when running player:LoadCharacter()?

1 Like

Literally nothing. I don’t know what’s going on.

1 Like

Have a look at the code in this wiki post

You’ll need to create a remote event that fires when the player clicks the start button, then the server will receive it and load the players character

1 Like

What’s not working? Is the character not loading or is it loading but not when you press the start button?

1 Like

It doesn’t do anything when I press the button assigned to it.

1 Like

Server Script

local PlayerService = game:GetService("Players")

PlayerService.CharacterAutoLoads = false

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local GUI = game.ReplicatedStorage:WaitForChild("GUI")


PlayerService.PlayerAdded:Connect(function(player) -- Once the player joines the game, the button appears on their screen
	local playergui = GUI:Clone() 
	playergui.Parent = player.PlayerGui
end)
Event.OnServerEvent:Connect(function(plr) -- Once the player clicks the button, they spawn
	plr:LoadCharacter()
	PlayerService.CharacterAutoLoads = true
end)

Local Script

local Button = script.Parent.TextButton
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Button.MouseButton1Click:Connect(function() -- Once the player clicks the button, this function fires a remote event
	Event:FireServer()
	script.Parent:Destroy()
end)
6 Likes

Have you set up remote events to facilitate communication between your GUI ( local ) and server script?

Close the GUI is simple. You can simply set it GUI.Visible= false once it’s done.

1 Like

Thank you for this, I needed this because i am making an fps game, it is really useful for making spawns :slight_smile:

2 Likes

I found a easy way to do this after reading a bit of posts and learning how to script!

Here’s the file if you want it
Menu.rbxm (5.0 KB)

Thanks everyone for helping!

1 Like