Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

Thanks, but I changed it on my own by putting the vector3 as (0,-b,0)

This discussion is preserved as it was. New answers, comments, and votes are closed.