Good day !, I’m trying to move 3 blocks at the same time but with different directions (all in one script), I really tried with many things coroutine, functions and many more things but I could not do it correctly the way I could do it is put a script in each block but I do not like that. I think there is a great way to do it but I am not aware if someone could help me how to do it I would really appreciate it.
Note: It is a movement with Effect I used the for loop and vector3 to make a smooth movement effect, although I could also use: Lerp () but more precisely I came out with for What do you recommend?
Thanks for your attention.
Script that I made:
local Part = script.Parent
while true do for i = 9, -51, -1 do
local MoveToPosition = Vector3.new(i, Part.Position.Y, Part.Position.Z)
Part.Position = MoveToPosition
wait(0.001)
end
wait(1)
for i = -51, 9, 1 do
local MoveToPosition = Vector3.new(i, Part.Position.Y, Part.Position.Z)
Part.Position = MoveToPosition
wait(0.001)
end
when the interpolation ends at the indicated position when I activated the option “Reverse” (true) It does not wait for 1 second and returns to the position it was in. How can I make him wait a few seconds and then go back to where he was?
I’m afraid you will have to create two separate tweens (one forwards, other backwards), and play them sequentially with appropriate wait() between them.
You would record the position at the start, then when the tween is over you would wait a few seconds and tween it back to that recorded start position.