Hello fellow developers! Recently, this weird problem occurred. When any player dies, they don’t respawn. AutoCharacterLoads is set to true and the respawn time is 5. (Don’t worry I waited more than 5 seconds). I have no clue on how this could have happened, and help is really appreciated! Thank you for reading, and enjoy your day! Also I tried fixing it by using this, but no sucess
local connection = {}
local DTeamSpawns = game.Workspace.Spawns:GetChildren()
local chosen = DTeamSpawns[math.random(1,#DTeamSpawns)]
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid", 100)
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 100)
if connection[Player] then
connection[Player]:Disconnect()
connection[Player] = Player:GetPropertyChangedSignal("Team"):Connect(function()
if HumanoidRootPart and Player.Team.Name == "D" then
HumanoidRootPart.CFrame = chosen.CFrame
end
Humanoid.Died:Connect(function() Player:LoadCharacter() end)
end)
end
end)
end)
Is there anything suspicious with this script? When I removed it the player respawned, but the players camera just looks at the ground
--Stop automatic spawning so it can be done in the “PlayerAdded” callback
game.Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
--Create a HumanoidDescription
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "0"
humanoidDescription.BodyTypeScale = 0.1
humanoidDescription.ClimbAnimation = 619521311
--pawn character with the HumanoidDescription
player:LoadCharacterWithHumanoidDescription(humanoidDescription)
end
--Connect “PlayerAdded” event to “onPlayerAdded()” function
game.Players.PlayerAdded:Connect(onPlayerAdded)
Ok the camera is stuck where the player is looking
You do not need to add a new HumanoidDescription. The player already has a HumanoidDescription. If you want to change it, change the properties of the current HumanoidDescription. To fix the camera, go to Workspace → Camera → CameraType. CameraType is all the way at the bottom. Make sure the type is Custom
Your issue here is you are not setting anything as the connection on the connections table. You are using an if statement to check if the connection exists, but it’s nil.
Had a problem like this a while ago. Player wouldn’t respawn if they used the reset button, but they would if they died from something else. I just disabled the reset button.
they are all signals, you must check if the player joined before PlayerAdded is connected, or the character is added before CharacterAdded is connected, or team has changed before its connection is made.
another approach to this is enabling CharacterAutoLoads and setting RespawnTime to 0 in Players service properties