How can I "save" & "load" info about tweening parts when player joins?

Hello, sorry if this is messy but I’ll try my best to explain this:

There’s a server script that every X seconds fires a remote event, when the remote event get listened by the player’s client, it creates a new part and start a “tweening loop”, there are pre-placed parts named “Part1”, “Part2”, “Part3” etc to dictate the tweening path.

This is to have all players have the same parts, tweening to the same positions, at the same time. Having a smooth tweening because it’s done on each client and not from the server.

The problem is that, when a player joins, he cannot see “older” parts that spawned and started their tweening loop for, maybe, players that joined the server a couple minutes / hours before.


I tried my best to explain this with an image:


So, how could I “save” the tweening info (where is the part currently and to which part does it need to tween) so I can “load” them when a new player joins and have all players seeing the same parts, in the same place, tweening to the same Waypoint, as players that joined the server before?

I thought maybe through a table that updates somehow everytime a tween from pointA to pointB finishes, but I have no clue on how to actually “save” and “load” these information.

Thank you in advance!

3 Likes

You could store the TweenInfo (the part, the actual TweenInfo, etc) in a table. Then, every interval of x, you could check if the client has those changes and if not, you could send over the table and then do as you would.

1 Like

I am not passing anything by the server though, everything is calculated / done on each client via a client script (the tweening loop, the speed, etc)

1 Like

You should create the parts and tweens on the server script instead.

You can also do

local a = -- this is a tween
local b = -- this is the second tween
a:Play()

a.Completed:Connect(function()
       b:Play
end)
b.Completed:Connect(function()
       a:Play
end)

You can also add bool values into replicated storage and fire the remote once the player joins.

e.g part 1 is being tweened for everyone, make instance.new(“boolValue”) and mark it as true (make sure it’s created in a server script) then make it look if that instance is true and if it is then it starts the tween.

The problem is that I do not want to create tweens on the server, because they are laggy.