Teleporting back and forth while being stuck in a part

Yeah, the script that I’m using is meant for one way teleportation but I was trying my hand at 2 way teleportation with it

Replace your script with this. Then it should work

1 Like

Both scripts or just one of them?

Replace both scripts.

Ignore this its because of the new rule.

1 Like

I suggest using char:MoveTo(position), instead of CFrame since it will move it to the nearest position while allowing your player not to get stuck in the ground.

1 Like

What does TpPart in your script stand for?

It’s an actual part in your Portal model that needs to be added!

:MoveTo() is a built in roblox function for groups/models. It’s a Vector3 rather than a CFrame and since it’s a Vector3 you don’t collide inside of parts it will place the model right on top of the part you’re positioning the player into.

1 Like

I did what you said. Replaced both scripts and here is what happened:

Video

But somethimes there occur errors if a accecorie touches the trigger of the teleporter.

Show your code, and I can help fix those issues.

1 Like

You should place the part where the player is teleported to not directly above the trigger of the other teleporter. Otherwise you will instantly trigger the other teleporter. Place it 5-10 studs apart from the trigger.

1 Like

53%20PM
Original code:


Code @Nova_MrRoyal suggested (which the last video demonstrated):

Oh wait I removed avariable on accident.

above the “local humanoid = char.humanoid” there needs to be

local char = hit.Parent

If u send me a friend request and activate Team Create I could help u manage this.

1 Like

Okay, good to know. By the way, I moved the teleports further apart and this happened:

Cuz u didnt move the teleport part with it.

1 Like

MoveTo is less glitchy than CFrame, because it ignores collisions. Make sure “TpPart” is facing the way you want the player to teleport (front surface).

local tp = workspace.TpPart
local debounce = false

script.Parent.Touched:Connect(function(hit)
        if debounce == false then
	       if hit.Parent:FindFirstChild("Humanoid") then
		    local character = hit.Parent
		    character:MoveTo(tp.Position + tp.CFrame.lookVector * 2)
                    wait(1)
	      end
              debounce = false
        end
end)

You will get an error if you use it, also :GetPlayersFromCharacter() yields the script, causing a slow down.
Remove game.ReplicatedStorage.ChangeSky:FireClient() and local player = game.Players:GetPlayerFromCharacter(char) and replace game.Workspace[player.Name].HumanoidRootPart.CFrame = teleport.CFrame with humanoid.RootPart.CFrame = teleport.CFrame

The trigger is the part the script is parented to. You should move the TpPart away not the whole teleporter

Now the script doesn’t even work.