Replicating tweens across all clients

Helloooo,

So I’m in the process of making a tower defence game.

After looking through the forums I saw the most efficient way of moving NPCs along the map would be to use CFrame, after a few stress tests I found that this was the best way even on mobile. Currently the server spawns them into the map and then the client uses the TweenService to move them.

However, one issue I’m going to encounter is if two players are in the same game then the NPCs they see may be in a different position to where the NPCs are on the other players screen because maybe they have a potato PC or there was a small lag spike, etc. which caused them to lag behind a bit.

So I was wondering if anyone has a smart solution to make sure the zombies are in the same position across all clients, as if they were being tweened on the server.

Thanks to any help in advance!

3 Likes

Alternatively, you could create a folder in ReplicatedStorage titled along the lines of ‘NPCs’. For every NPC, create a new CFrameValue in this folder. When you wish to move an NPC, change the value of the CFrameValue to the target CFrame of the NPC. Finally on the client, detect when this CFrameValue is changed, and move the NPC accordingly.

If you have lots of NPCs, I’d recommend using SteadyOn’s method.

10 Likes

This is the most gorgeous thing I’ve seen thank you

3 Likes

Hey, did it work as expected? I am currently in need of something similar, where the players see the parts at the same place at the same time.

Thanks for any answer!