Tele.Touched:connect(function(part) -- 3
if part.Parent.Humanoid then -- *
if part.Parent.Humanoid.Health > 0 then -- 4
part.Parent:MoveTo(AnotherBrick.Position) -- 5
end
end
end
And when I add a roof above the part that teleports, it just puts me above roof, Can someone help me?
I do not know much about scripting so a little help on a teleportation system?
The issue is that you are using MoveTo, which uses Vector3
Vector3 factors in collision, so you should use CFrames. CFrames do not. For example, if you try putting a part inside of another part with Vector3’s, the part will keep moving up until it is no longer colliding. With CFrames, this does not happen and you can put parts inside other parts with no problem.
The switch from Vector3 to CFrame is very easy, you can construct a CFrame from a Vector3 like this:
CFrame.new(v3)
Tele.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
part.Parent:SetPrimaryPartCFrame(CFrame.new(AnotherBrick.Position))
end
end)
The primary part of a player character is the humanoid root part. So this is just moving their primary part.