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.
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.
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.
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!
local part = script.Parent
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumnaoidRootPart.CFrame = "Checkpoint CFrame"
This code may have typos I didn’t check it for spelling errors in the strings.
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.
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
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)
From there, any part inside of the “KillParts” folder will teleport the player to their checkpoint when touched
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
local hum = char:WaitForChild(“Humanoid”)
if lava:IsDescendantOf(char) then
char.HumanoidRootPart.CFrame = checkpoint.CFrame