I’m using a starter character for my game. The only problem is when it falls off the baseplate, it does not die and respawn. Instead it hangs in the air forever. I want the character to respawn when falling off the baseplate.
I’ve tried searching for a solution but found no information on what kills the character when it falls off the baseplate. Is it a property that needs to be set or do I need to write my own script for my own starter character to respawn?
Any help you can offer on this topic is greatly appreciated. Thank you.
ps. I know you can use the standard R6 and R15 rigs for the starter character, and those work fine. But here I want to use a non-standard character without the usual parts of a standard character.
The workspace has a property called “FallenPartsDestroyHeight” which will destroy the character once it reaches that y value. The default is -500 so try increasing it to whatever works for your game.
A simple solution would be to use a loop to keep checking the position of the player. If Y position is lesser than say the default “-500” or some other number, the player will get destroyed and respawned.
Something like this:
local connection
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
connection = game:GetService("RunService").Heartbeat:Connect(function()
if character:FindFirstChild("HumanoidRootPart").Position.Y <= -500 then -- if player is at the destroyheight
connection:Disconnect() -- disconnects the function because the code will run again due respawn
character:Destroy() -- deletes character
wait(2) -- respawn time
player:LoadCharacter() -- respawns character
end
end)
end)
end)
Thanks for your help. I have set it to -50, but it still does work. The character’s body parts are destroyed, But the character itself (Health, Humanoid, and Animate) is still in the workspace. And no error message in the output window. It must be something to do with the fact that my character has a non-standard rig.
Thanks for your help. I have inserted your script into the serverscriptservice, but it still doesn’t work. Now there is an error message in the output window. You see the character’s body parts are destroyed when the character falls off the baseplate, but the character itself (Health, Humanoid, and Animate) is still in the workspace. And since the HumanoidRootPart no longer exists, it is causing the error when tried to get the position of the HumanoidRootPart.
Try it now.
I removed the destroy and instead player’s root part will get anchored to prevent the player from falling further. This should hopefully fix the player-destroying problem.
local connection
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
connection = game:GetService("RunService").Heartbeat:Connect(function()
if character:FindFirstChild("HumanoidRootPart").Position.Y <= -400 then -- if player is at the destroyheight
connection:Disconnect() -- disconnects the function because the code will run again due respawn
character:FindFirstChild("HumanoidRootPart").Anchored = true -- anchors to prevent further falling
task.wait(0.5)
player:LoadCharacter() -- respawns character
end
end)
end)
end)
But just out of curiosity, do we know why it needed extra code for my character to respawn as opposed to a regular normal character? I mean my character does respawn normally when its health is set to zero. So what I did in my game prior to this was instead of LoadCharacter() as you did, I watch for when the character falls off the platform and I set its health to zero.
By the way, does LoadCharacter() fires the Humanoid.Died event so the character gets reset?
Your script is a very nice script, I really like it. Thanks again.
I would love to help you out but I’m not sure about what caused that. I’m also kind of new to scripting so I’m not well informed about all that stuff.
Also, I don’t think LoadCharacter() fires the Humanoid.Died() event due to the died event firing when the player’s health reaches zero. Although you can make it so that the player takes damage equal to the player’s max health so that would also fire the died event.
Also, I just realized that it would have been better to just check if the player doesn’t have their humanoidrootpart in the character and fire the player:LoadCharacter() function instead of doing all the checking and stuff. That would fix the respawning as the rootpart is destroyed when falling into the void.
Anyways, Goodluck.
Yes that’s exactly what I did in my game, checking for the HumanoidRootPart and set Humanoid.Health = 0. That did it and it also fires the Humanoid.Died event, because there are things that I needed to do when the character dies. I do appreciate the help and again I really like your scripts, they are very clear. Wish u the best!