Basically on test run when I touch the red, it does bring me back to the Orange block (Named TeleportTangerine). However, I am stuck in the block.
I would like to know if there is a way to teleport the humanoid to be standing on top of that block, or to teleport the human to just be touching the block.
Here is my code so far:
local pad = script.Parent
local teleportTo = workspace.TeleportTangerine
pad.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
if humanoidRoot then
humanoidRoot.CFrame = teleportTo.CFrame
end
end
end)
Thank you for your help in advance, I am pretty new to scripting >.<
Maybe you can try block.Position + Vector3.New(0,5,0), or just call
Humanoid.Parent:MoveTo(tangerineblock.Position)
(note the humanoid.Parent) since the player character is a model. If you want to use MoveTo() in the future though, you need a primary part for the model you’re moving but the player character itself has a primary part
You could just set the teleport block to not cancollide if there is a block underneath to stop you from falling into the void, or you could simply teleport the player to above the block by adding 3 studs onto the Y Coordinate.
do humanoidroot.CFrame = teleportto.CFrame + Vector3.new(0,2,0)
The problem here is that when you set a position that position is in the center of the object so you teleport the rootpart inside the center of the object
Your script works, maybe you should add an invisible and unenabled CanCollide brick on the tangerine.
local pad = script.Parent
local teleportTo = workspace.TeleportTangerine -- put the invisible and unenabled CanCollide brick name for the workspace
pad.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
if humanoidRoot then
humanoidRoot.CFrame = teleportTo.CFrame
end
end
end)