Alrighty, there are 2 ways of doing this, im gonna explain both for your knowledge
First, we get the part, and create 2 for loops
movingPart = script.Parent
for i = 1, 10 do
end
wait()
for i = 1, 10 do
end
The for loop will count from 1 to 10, which we can then use to increase and decrease the position
We will now add a while loop (so this gets repeated until said so) and we will add the moving position of the part
movingPart = script.Parent
while wait(1) do
for i = 1, 10 do
movingPart.Position = Vector3.new(0,0 + i,0)
wait(0.09)
end
wait()
for i = 1, 10 do
movingPart.Position = Vector3.new(0,0 - i,0)
wait(0.09)
end
end
Now, we will do it the much more efficient way. It is more efficient because if you move the part, it still goes up and down, whereas if we use the method above, you would have to change the position every time the parts position is moved
local movingPart = script.Parent
while wait(1) do
for I=1,10 do
movingPart.CFrame=brick.CFrame+Vector3.new(0,1,0)
wait()
end
wait()
for I=1,10 do
movingPart.CFrame=brick.CFrame+Vector3.new(0,-1,0)
wait()
end
end
I hope this helped increase your understanding of CFraming and positioning!
1 comment
lol the other guy forgot lerp