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.

01local c = script.Parent
02debounce = false
03 
04function onTouch()
05    if debounce == true then return else
06        debounce = true
07    end
08    if c.Position == Vector3.new(-242, -18, 231) then
09        c.Position = Vector3.new(-243, -16, 228) else
10        c.Position = Vector3.new(-242, -18, 231)
11    end
12    wait(1)
13    debounce = false
14end
15 
16script.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.

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

Answer this question