Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part Teleportation acting weird?

Asked by 7 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

Position snaps, CFrame doesn't.

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

Answer this question