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

I need to shorten a long script about vector3 and i dont know how?

Asked by 4 years ago

Hey, i have a long script and it feels tedious, i feel like it could be simplified to a standard that meets everyones expectations, here's the script

while true do
    -- Step 1
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position - Vector3.new(0, 0.125, 0)
    wait()
    -- Step 2
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0, 0.125, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston2.Position = script.Parent.Piston2.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston3.Position = script.Parent.Piston3.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston4.Position = script.Parent.Piston4.Position + Vector3.new(0, 0.125, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0.125, 0, 0)
    script.Parent.Piston5.Position = script.Parent.Piston5.Position - Vector3.new(0, 0.125, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0.125, 0, 0)
    script.Parent.Piston6.Position = script.Parent.Piston6.Position + Vector3.new(0, 0.125, 0)
    wait()
end

thank you for helping

0
I remember a question like this lol it got me like 5 upvotes greatneil80 2647 — 4y

1 answer

Log in to vote
1
Answered by
sebanuevo 123
4 years ago
Edited 4 years ago

This code should help

function repeatThis()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position - Vector3.new(0.125, 0, 0)
    wait()
    script.Parent.Piston1.Position = script.Parent.Piston1.Position + Vector3.new(0, 0.125, 0)
end

while true do
    repeatThis()
    wait()
end
0
not at all 123jangamer321 28 — 4y
Ad

Answer this question