Does anybody know how I can script a “kill brick” that doesn’t actually kill, but teleports you back to the checkpoint? I want to make a mini-obby for my homestore (I’ve seen some other homestores have that and got inspired by it). I don’t want to reset the player, just have them teleport back to the checkpoint. I’ve tried to look it up on youtube like one way teleporters, but obviously I want to have more than one “kill brick” and I cant seem to find out how to have multiple teleporters[kill bricks] go to one spot[checkpoint/spawn].
local Part = workspace.PartThatNeedsToBeTouched
--^ you could put a script inside a part and just use local Part = script.Parent
Part.Touched:Connect(
function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
Hit.Parent.HumanoidRootPart.CFrame = workspace.PartThatYouTeleportTo.CFrame
end
end)
Is there only going to be one checkpoint
that they’ll get teleported to? If so, you can try something like this (a Script
in ServerScriptService
):
local checkpoint = workspace:WaitForChild("Checkpoint")
local killbricks = workspace:WaitForChild("Killbricks") -- folder with killbricks
local function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health > 0 then
hit.Parent:MoveTo(checkpoint.Position + Vector3.new(0, 2, 0))
end
end
for _, killbrick in pairs(killbricks:GetChildren()) do
if killbrick:IsA("BasePart") then
killbrick.Touched:Connect(onTouch)
end
end
yes, i will try this, thank you
I edited it because I forgot that I renamed one of the variables. Try that version. Old variable name was obbySpawn
but I changed it to checkpoint
. If it errors that’s why .
do i put the folder of killbricks in replicated storage? I’ve done that before when scripting things but this time when i put them in the folder they all disappeared. do you know why?
Put the folder under workspace and put the killbricks inside of that folder, like so:
ah, thats how I had them. i’m not sure where I got the idea of putting them in replicated storage though. i’ll try the script now and see if it works
Is the checkpoint a model or a part? The way I made it, I assumed it was a Part
.
i can change it to a part, i had made it into a model because I had text on it and grouped it but i can ungroup it real quick
i fixed it and it worked! thank you so much for your help.