Hello fellow developers!
I’m currently developing a tower defense game with the help of some of my friends, but we’ve ran into a problem when handling the enemies.
What we’re currently doing is spawning these enemies in server but moving them in client which works perfectly when there’s only 1 player, but the more players there is, the more the system starts breaking. Which has made me think what we should instead do is spawn and move in server-side, but render them in client-side. Is there anyway i can achieve this? Thanks for reading!
Just spawn and move them server-side. The changes will be replicated to all the clients automatically like any other instance.
The server never renders anything in the first place
What you can do is create a table of all the enemies that are in-game. When a player joins, fire a remote event from the server to the client with all the positions of the enemies and then from the client move the enemies to said position. From there you can setup a function on the client that “observes” the position of the enemies for the duration of the game.
Wouldn’t a module script work?
Just do it as @nicemike40 said and move them on the server. It is the best thing to do, as creating them on the client can result in all players not being in sync. If you run it from the server it is in sync.
That method would create a lot of lag when you spawn in tons of enemies.
I guess you could tween the Enemies position with TweenService2.
TweenService2 ended up working better than the system i was using. Thank you!