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

Part position and Vector3.new() help?

Asked by 8 years ago

So I'm trying to get my part to go up and down while the script is true (while it is), but the part just sits on top of another part and does nothing.

while true do
    script.Parent.Position = Vector3.new(-31.4, -0.985, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.785, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.585, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.385, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.185, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, 0.015, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.185, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.385, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.585, 1.695)
        wait(0.0001)
    script.Parent.Position = Vector3.new(-31.4, -0.785, 1.695)
        wait(0.0001)
end
0
Use CFrame. User#11440 120 — 8y

1 answer

Log in to vote
1
Answered by
Uglypoe 557 Donator Moderation Voter
8 years ago

When you set the position of a part already in the Workspace, it places it at that position. However, it the checks if the part is colliding with any other parts. If so, it will put it at the highest point above that position where it no longer collides with parts.

To fix this, you can enclose your positions in a Crame.new, and apply it to script.Parent's CFrame. I did this below for you to see. Also, I'd recommend using a iteration loop instead of manually writing out each individual position! :)

Also note that the minimum time a wait() can, well, wait is 0.03. Anything below that automatically changes to that, so you might as well not supply a value to your wait()s at all.

while true do
    script.Parent.CFrame = CFrame.new(Vector3.new(-31.4, -0.985, 1.695))
    for i=1,4 do
    wait()
    script.Parent.CFrame = CFrame.new(script.Parent.Position + Vector3.new(0,0.2,0))
    end
    wait()
    script.Parent.CFrame = CFrame.new(Vector3.new(-31.4, 0.015, 1.695))
    wait()
    script.Parent.CFrame = CFrame.new(Vector3.new(-31.4, -0.185, 1.695))
    for i=1,3 do
    wait()
    script.Parent.CFrame = CFrame.new(script.Parent.Position - Vector3.new(0,0.2,0))
    end
     wait()
end

Sorry that the spacing is terrible, I blame iPads.

If you need any more help, feel free to let me know! :)

0
I too hate Ipads. User#11440 120 — 8y
Ad

Answer this question