Cant get my Teleport Script working

Sorry im really new at Scripting, I can’t seem to get my teleport script working. basically what its meant to do is when the player steps on the block the gets teleported to the other block.

1 Like
script.Parent.Touched:Connect(function(hit)
       hit.Parent.HumanoidRootPart.CFrame = workspace.Part.CFrame
end)

I’m on mobile so i can’t check if it is correct.

1 Like

I would recommend next time you use the search bar as there are many threads on teleporting.
More so the fact a recent thread was given a good answer that has the same issue you are having.

1 Like

I have a feeling it has to do with you having the variables a bit odd which is showing by the red line before “HumanoidRootPart” The rest of your code looks fine.
The other thing is at the top you have two functions which aren’t called further down so you aren’t connecting the Touched event.

image

2 Likes

It’s not the same…

30 characters

1 Like

Sorry were would I add that in the code?

1 Like

It is the same, it has the same intention.

Please stop trying to gain solutions, this could’ve been solved with one simple search.

1 Like

First, please use Code Blocks simply by typing “`” three times


Second, You are connecting your function before even decalring them try this:
local Part1 = wokrspace.Part1
local Part2 = workspace.Part2
local DeBounce = false

function OnTouchOne(hit)
 -- Code Here
end

function OnTouchTwo(hit)
 -- Code Here
end

Part1.Touched:Connect(OnTouchOne)
Part2.Touched:Connect(OnTouchTwo)

Third do not name your function exactly as your parts the will override your parts when you define them

Replace the whole code with mine code.

2 Likes