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

Why does this C-frame script keep going up, not down?[SOLVED ON MY OWN]

Asked by 9 years ago

No errors, but i need to know how to fix this so after these two parts go up, after 5 seconds, it goes down to its original position.

part = script.Parent.Part
part2 = script.Parent.Part2
function move()
    for i= 0.1 ,50 do
        wait(0.1)
        b = 0.1+0.1
    part.Position = part.Position+Vector3.new(0,b,0)
    part2.Position = part2.Position+ Vector3.new(0,b,0) 
    script.Parent.ClickDetector.MaxActivationDistance = 0
    end
    wait(5)
    for i= 0.1 ,50 do
        wait(0.1)
        b = 0.1+0.1
        part.Position = part.Position+Vector3.new(0,b,0)
        part2.Position = part2.Position+ Vector3.new(0,b,0)
        script.Parent.ClickDetector.MaxActivationDistance = 32
end
end 

script.Parent.ClickDetector.MouseClick:connect(move)

1 answer

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
9 years ago

You are still adding in the second part, you need to subtract:

part = script.Parent.Part
part2 = script.Parent.Part2
function move()
    for i= 0.1 ,50 do
        wait(0.1)
        b = 0.1+0.1
    part.Position = part.Position+Vector3.new(0,b,0)
    part2.Position = part2.Position+ Vector3.new(0,b,0) 
    script.Parent.ClickDetector.MaxActivationDistance = 0
    end
    wait(5)
    for i= 0.1 ,50 do
        wait(0.1)
        b = 0.1+0.1
        part.Position = part.Position-Vector3.new(0,b,0)
        part2.Position = part2.Position- Vector3.new(0,b,0)
        script.Parent.ClickDetector.MaxActivationDistance = 32
end
end 

script.Parent.ClickDetector.MouseClick:connect(move)

0
Thanks, but I changed it on my own by putting the vector3 as (0,-b,0) My_Comment 95 — 9y
Ad

Answer this question