Atm Im trying to make a system where the users join the game and end up in a loading screen where the camera is tweened over the map of the game. During this process the character should not load up until the loading screen is finished.
So far, I have tried turning off character auto loads and everything works fine however when people eveutually load and die when playing they won’t respawn because characterautoloads is off. Keeping characterautoloads on doesn’t let me tween the camera as it’s focused on the character when it spawns.
The tweening of the player’s camera and such is done on the client in the ReplicatedFirst.
Is there a way to stop the character from loading just for a period of time or another way to go around this?
You can disable CharacterAutoLoads and implement your own listener to respawn the player character when they die.
local players = game:GetService("Players")
local respawnDelay = 5
-- runs when a player spawns in
local function handleCharacter(character)
local humanoid = character:WaitForChild("Humanoid")
if (humanoid ~= nil) then
-- runs when a player dies
humanoid.Died:Connect(function()
wait(respawnDelay)
local player = players:GetPlayerFromCharacter(character)
if (player ~= nil) then
player:LoadCharacter()
end
end)
end
end
-- runs when a player enters the game
local function handlePlayer(player)
if (player.Character ~= nil) then
handleCharacter(player.Character)
end
player.CharacterAdded:Connect(handleCharacter)
end
-- people who might be in the game before the script runs
for _, player in ipairs(players:GetPlayers()) do
handlePlayer(player)
end
-- people who joined after the script runs
players.PlayerAdded:Connect(handlePlayer)
@Little_Joes After the loading screen the character spawns via Player:LoadCharacter()
The solution I came up with for this is to use the Humanoid.Died event which loads the character manually and keep characterautoload off. This way whenever the character dies, there’s the event listening.
Just realized @Blokav recommended the same thing so I will give him the solution.