As mentioned in the title of this post, I am currently trying to create 120+ objects which are all identical to each other, move in the same curved path. This path is only composed of lines and curves in the shape of a circle.
To make things easier, I will simplify my problem. The diagram shown above is pretty self explanatory. The blue circles are the objects I would like to move, and the path is not an oval. It is composed of 2 lines and 2 half circles. The objects will move in a single direction along the path while maintaining a certain velocity.
To program this system, I decided to use
TweenService since I would like the movements to be clear. There is p1 which is a position at the center of the half circle on the left, and there is p2 at the center of the half circle on the right. Each object is welded to another part, which is what is going to be tweened. These parts are tweened from p1 to p2, tweened 180 degrees, tweened from p2 to p1, and finally tweened 180 degrees to return to the original location. I created a script in
ServerScriptService and fired a
RemoteEvent to all clients using
--Server local function beginMovement(model) RemoteEvent.FireAllClients(tween_info_stuff1) task.wait(3) RemoteEvent.FireAllClients(tween_info_stuff2) task.wait(3) RemoteEvent.FireAllClients(tween_info_stuff3) task.wait(3) RemoteEvent.FireAllClients(tween_info_stuff4) task.wait(3) end for _, model in pairs(modelFolder:GetChildren()) do task.wait(3) local beginFunction = coroutine.wrap(function() beginMovement(model) end)() end --Client RemoteEvent.OnClientEvent:Connect(tween_info_stuff) local tween = tweenService:Create(tween_info_stuff) tween:Play() end)
Note that this script is a simplified version of the original script, I just took the necessary parts to explain.
Now, there are a few things that I am struggling with. Let’s say the time of the tween from p1 and p2 and vice versa takes 20 seconds, the half circle movement takes 10 seconds, and the time delay between each objects is 3 seconds. How can a player who joined a server that has been running for an hour see the same thing others see? How can I make sure there is always a 3 seconds difference between objects? Is this even the best method of moving objects?
I have been struggling with this issue for a while now, and would appreciate any help or suggestions. Thank you so much for reading this long post.