Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Teleport to Most Recent Checkpoint on Death? (Obby)

Hello. I am trying to make a really nice obby, but I want a death system similar to what Mega Fun Obby has. When you die, you got teleported instead of actually die. I am newer to Lua and I am not sure how to do this. Any help with this would be appreciated.

Thanks, Vollaway

1 comment

3 answers

Assuming that you have a leaderstats already setup and a folder called 'Stages' to store the stage. Create a part at the bottom of all the stages, so when the player falls, they will hit the part. Copy paste this script into said part.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health > 0 then -- Make sure player exist and is alive
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local HumanoidRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
		if Player and HumanoidRootPart then
			local leaderstats = Player:FindFirstChild("leaderstats") -- Get stats of the player
			HumanoidRootPart.CFrame = game.Workspace.Stages:FindFirstChild(leaderstats.Stage.Value).CFrame -- Assuming that the stages is stored in a folder named 'Stages' and the part is the spawn
		end
	end
end)

Hope this helps and remember to accept it it did! If there is an error, report it to me and I will try my best to fix it asap!

1 comment

0

Okay, so it is a teleport script, but it needs to be teleporting back the last checkpoint when you fall or get hit with a kill brick. Basically, instead of the character dying, I want the character to directly teleport back to the last checkpoint that was touched. I would assume this could be achieved by putting that script into an invisible brick and replacing kill scripts with that script.

The answer above me is quite correct but there is just one more step to it.

Select your spawn and in properties look for Team Change On Touch or something like that and check the box. Also if you haven't already for the checkpoints after the first one make sure it is not neutral (also in properties).

If this helped please accept this answer.

I'm not 100% sure, but as far as I know, you don't need to script anything. When you touch a spawn point it automatically sets it as your spawn point. Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.