Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Part Teleportation acting weird?

So I'm alright with lua I would say but not completely advanced and I was confused with vector3 and CFrame's but now I do know but I was testing both and my problem is the part I have here doesn't teleport correctly. When I'm not inside the coordinates of the part where it's going to teleport, it works fine. But when I am inside the coordinates the part teleport aboves me. Not sure how you would fix this and it does the same thing with a moving part that goes up and down. I put the code below.

local c = script.Parent
debounce = false

function onTouch()
	if debounce == true then return else
		debounce = true
	end
	if c.Position == Vector3.new(-242, -18, 231) then
		c.Position = Vector3.new(-243, -16, 228) else
		c.Position = Vector3.new(-242, -18, 231)
	end
	wait(1)
	debounce = false
end

script.Parent.Touched:connect(onTouch)

1 answer

Position snaps, CFrame doesn't.

c.CFrame = CFrame.new(-243, -16, 228)

This discussion is preserved as it was. New answers, comments, and votes are closed.