Help with a tp system for an obby

Hello developers,
I’m trying to make a teleporting system whenever a player touches a lava block, instead of dying, I wasn’t them to teleport to the checkpoint they were at. Read below for more information. Please answer them if you can.

  1. What do you want to achieve? Whenever a player touches a lava block, instead of the player dying, I want them to teleport them to the checkpoint they were at.

  2. What is the issue? I do not know what the script to that is. I’ve searched it up on YouTube and I’ve found no tutorials.

  3. What solutions have you tried so far? I’ve searched it up on Google and YouTube and I’ve found nothing so far.

Please help me on this situation. Anything would help. Thanks!

1 Like

What you could do is each time the player reaches a new checkpoint you save it on the server and then teleport the player back to the position of the checkpoint.

2 Likes

When the humanoid dies, check, and then set their HumanoidRootPart or Torso position to the desired checkpoint.

Humanoid.Died:Connect(function()
-- stuff
end)
2 Likes

Thank you for the feedback, I’ll see if this works.

1 Like
local part = script.Parent

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
       if hit.Parent:FindFirstChild("HumanoidRootPart") then
           hit.Parent.HumnaoidRootPart.CFrame = "Checkpoint CFrame"
       end
    end
end)

This code may have typos I didn’t check it for spelling errors in the strings.

2 Likes

Thank you for the feedback, I’ll see if this works. :smiley:

Thank you for your feedback, I’ll see if this works.

You don’t need to wait for the humanoid to die to move it. At that point you might as well use Spawn Locations.

Also, the reason you didn’t find any tutorials, is because your request was specific.

You can just learn some lua and copypasting code won’t help at all (since you wont understand it)

3 Likes

This means he will have to create a script for every lava part…

2 Likes

I’m not aiming to provide good code. Obviously it would be better to use a Folder and loop through the folder. When you’re new to scripting it’s best to not add extra complexity to something you still haven’t yet learned.

1 Like

He can use CollectionService instead of creating hundreds of scripts.
Edit: Or the method Zylter suggested.

1 Like

Thank you everyone for your help. I’ll see if any of them help! :smiley:

1 Like

Well, if you have a leaderstats of the player’s stage, a quick way to do this is to make a folder of all your lava bricks. From there, name the folder “KillParts” or something, and this code applies to it. Also make sure to make a model/folder of all the checkpoints and name it “Checkpoints”:

local killparts = workspace:FindFirstChild("KillParts")
local checkpoints = workspace:FindFirstChild("Checkpoints")

for _, v in pairs(killparts:GetDescendants()) do
    if v:IsA("BasePart") then
        v.Touched:Connect(function(hit)
            local char = hit:FindFirstAncestorOfClass("Model")
            local player = game.Players:GetPlayerFromCharacter(hit)
            local stage = player.leaderstats.Stage --correct this if you have another name for the stage

            char.HumanoidRootPart.CFrame = checkpoints:FindFirstChild(stage.Value).CFrame + Vector3.new(0,5,0)
        end)
    end
end

From there, any part inside of the “KillParts” folder will teleport the player to their checkpoint when touched

4 Likes

Thank you for your feedback, I’ll see if this works. :smiley:

1 Like

try something like

local lava = game.Workspace.--name of your lava block
if lava.Touched then
Humanoid.Location == --wherever the checkpoint is

Hope that helped! That script may have some errors, i have no idea. Sorry if it does.

2 Likes

Thanks for your feedback, I’ll see if this will work!

1 Like

No problem. I have no idea if it does.

1 Like

Hey bro, I was just having the same problem as you, I was looking through these comments and couldn’t find anything which worked, if you haven’t already solved it yourself I found my own solution, let me know if you want me to share it with you.

you can do this by detecting if the player is touching the lava and if they are then they can tp to checkpoint
local player = game.Players.LocalPlayer
local lava = script.Parent
local checkpoint = script.Checkpoint

player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild(“Humanoid”)

hum.Died:Connect(function()
    player:LoadCharacter()
end)

hum.Jumping:Connect(function()
    if lava:IsDescendantOf(char) then
        char.HumanoidRootPart.CFrame = checkpoint.CFrame
    end
end)

end)