Proximity prompt help

I have a script that will teleport avatars to another part.

local teleport1B = script.Parent.Parent.TeleportReceiver

local canTeleport = true

function TeleportA(part)
	local hum = part.Parent:FindFirstChild("HumanoidRootPart")
	if hum then
		if canTeleport then
			canTeleport = false
			hum.CFrame = teleport1B.CFrame +Vector3.new(0,5,0)
			wait(5)
			canTeleport= true -- Sets the "Debounce" to true so it can teleport
		end
	end
end


script.Parent.Triggered:Connect(TeleportA)

This is a script inside a proximity prompt

1 Like

so whats the problem?, i didnt see any.
Also you can use :MoveTo(), instead of CFrame. its lot simplier and does a good job on performance

Try this, you usually have to use position.

local teleport1B = script.Parent.Parent.TeleportReceiver

local canTeleport = true

function TeleportA(part)
	local hum = part.Parent:FindFirstChild("HumanoidRootPart")
	if hum then
		if canTeleport then
			canTeleport = false
			hum.CFrame = teleport1B.CFrame +Vector3.new(0,5,0)
            hum.Position = teleport1B.Position + Vector3.new(0,2,0)
			wait(5)
			canTeleport= true -- Sets the "Debounce" to true so it can teleport
		end
	end
end

Move To wouldn’t work. It would move the humanoid to part without doing it instantly

Triggered passes the Player object instead of the Character so try changing to this line

local hum = part.Character:FindFirstChild("HumanoidRootPart")

yea instead of getting humanoidrootpart, try getting player model

local teleport1B = script.Parent.Parent.TeleportReceiver

local canTeleport = true

function TeleportA(part)
	if part then
		if canTeleport then
			canTeleport = false
            part.Character:MoveTo(Teleport1B.Position + Vector3.new(0,2,0))
			wait(5)
			canTeleport= true -- Sets the "Debounce" to true so it can teleport
		end
	end
end

script.Parent.Triggered:Connect(TeleportA)

I Always using MoveTo() instead of position or cframe. or you can use :SetPrimaryPartCFrame()
This Should Work Perfectly

Thank you, this works!! Quick question though, why did you set the Vector3.new position to 0,2,0? Previously it would move it to 0,5,0 and it worked good. (This teleports it but it puts on on top of the part (It may just be the way I designed the part that the player teleports to though)

oh, i see the problem. You cant use Vector3 On A CFrame

hum.CFrame = teleport1B.CFrame + Vector3.new(0,5,0)

You Cant use Vector3.New On A .CFrame Value
And I Change It From 5 to 2, So The Player Dont Teleport Too High From The Part. Preventing Hackers or low fps gamers