Hello i need help add to my script. I need to make it so the player does not spawn on the spawn pad until the game is done loading.
All the places / locations (Will not work)
local s = SpawnLocation1, SpawnLocation2, SpawnLocation3, SpawnLocation4,
game.Workspace.Spawn.Spawn.s
-----------------------------------------------------------------------------------------------
local goto = game.workspace.GoTo
end / loading screen skip
local bar = script.Parent.Bar
local insidebar = bar.Bar2
local percentage = bar.Percentage
local s = script.Parent.Parent.MainFrame.TextButton
s.Visible = false
wait(5)
insidebar:TweenSize(UDim2.new(1,0,1,0), "In", "Linear", 20, true)
wait(10)
s.Visible = true
wait(10)
script.Parent.Parent.EndSequence:TweenPosition(UDim2.new(0,0,0,0), "InOut", "Quad", 3, true)
wait(3)
script.Parent.Visible = false
script.Parent.Parent.EndSequence:TweenPosition(UDim2.new(-1,0,0,0), "InOut", "Quad", 3, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, true)
wait(3)
script.Parent.Parent.Parent.Loading:Destroy()
One way is too disable their spawning by going into Players and Disabling CharacterAutoLoads, you can then have the Loading Screen Play, and then go into the Player to fire :LoadCharacter() on the Server, you can probably have it so you fire a RemoteEvent which connects a CharacterAdded Event, Allowing them to spawn in.
So Basically: lets say you your loading screen is fiished, and you want to spawn in the Character, you can have a RemoteEvent fire to the server, letss call it LoadingFinished, what you would want to do is to use :FireServer(), which will send Data from the Client, to the Server
-- Lets say Loading Finishes Here
ReplicatedStorage.LoadingFinished:FireServer()
-- you can then fire a Event to the Server like so
The Server will know what Player the Event came from, and in return will give you the Player, from there, you can then say this:
ReplicatedStorage.LoadingFinished.OnServerEvent:Connect(function(player)
-- The Server will already know the Player it fired from, so you
-- can just apply the CharacterAdded Event here
player.CharacterAdded:Connect(function(char)
-- to detect whether the character
-- has spawned in
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.Died:Connect(function() -- to Detect when the Player Died
task.wait(3) -- the time it takes to respawn
player:LoadCharacter() -- Loads in the Players Character
end)
end)
player:LoadCharacter() -- Loads in the Players Character to apply
--CharacterAdded
end)