Script teleporting player to nowhere?

I have no idea what is happening. There is literally nothing wrong with my script. It just sends you to Narnia and I’ve tried everything.

local RS = game:GetService("ReplicatedStorage")

local UIManager = require(RS.UIManager)

local door = script.Parent
local toggle = door.Base.Toggle

local tp1 = door:WaitForChild("TP1")
local tp2 = door:WaitForChild("TP2")

local detector = door.Base.Detector

local went = false

detector.Triggered:Connect(function(player)
	local manager = UIManager.new(player)

	local hrp = player.Character.HumanoidRootPart

	manager:blackScreen(1)

	if went then
		hrp.CFrame = tp1.CFrame
	else
		hrp.CFrame = tp2.CFrame
	end

	toggle:Play()

	went = not went
end)

The positions are located correctly!

Video: https://gyazo.com/0c4d36d0eae3b9de3188639b529f2858

2 Likes

Try this instead:

if went then
	player.Character:SetPrimaryPartCFrame(tp1.CFrame)
else
	player.Character:SetPrimaryPartCFrame(tp2.CFrame)
end

The reason as to why you randomly go to the backrooms whenever you teleport is because you’re HRP variable is the character’s Torso. Bad idea because the whole character won’t go with the torso, instead you’ll basically glitch out.

2 Likes

Still didn’t work for some reason.

Try using moveTo() instead of CFrame.

I overviewed the script, and as you said, nothing is wrong with it. I believe the problem is with the actual teleport part(s), try and check those out.

Other than that, it looks good!

Possible problem :

  1. Forget to anchor the “tp1” and/or “tp2” Part
  2. Forget to Disable CanCollide The “tp1” and/or “tp2” Part

Hopes Help You!

if part is non anchored and cancollide is false the script will error since the part will destroy.

what

Umm, I don’t believe the part can self-destruct unless I’m wrong. It will just be laying on top of the part it’s on… :grimacing:

yea, the script will confused where the “tp1” or “tp2” is, instead teleport you to “void” or some sort of no where.

Normal studio the script will eventually errored like “Attempt To Index Nil With CFrame”. And Disabling CanCollide Didnt Destroy The Part Unless Youre Anchoring Them

It will fall into void destroying it, there is property in workspace to change the height where parts gets destroyed.

youre true but, part wil fall to the void if you disabling cancollide