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)
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
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)