Game is laggy in public server, but in studio it runs smooth

The title pretty much sums it up. When I join the game in a server it’s extremely laggy to the point where scripts don’t run properly, however in studio it runs perfectly fine.

In studio, everything is run on your own pc. Therefore clientsided, meaning that scripts that perform a lot of visual effects, like tweening or moving parts will appear choppy in game but smoother in studio.
To solve things like this, make sure to transfer anything visual (like a Shockwave or a explosion) on the client using localscripts. You can send a :FireAllClients() request. I don’t recommend running projectiles on the client though as latency will create a disconnect for the location of the projectile causing people to get hit, even though it looks like they dodged in on their screen.

If you have any further questions, or this did not solve your issue please let me know.

2 Likes

Thanks for responding , but I have all such effects played on the client and the only thing that really runs on the server are Region 3 hitboxes, raycasts, and damage dealing.

It could be the fact that multiple players are in your game in public and that is messing with something. Make sure you don’t have any wait() in your game(wait(number higher than 0.03) is fine). And check use your performance stats and micro profiler

2 Likes

Is it laggy when a server is first started or does it get more laggy as time progresses? If it starts off ok, you may have some form of memory leak. I’d recommend looking at the microprofiler to figure out what’s causing the biggest dips in performance.

Its consistently laggy ,but sometimes there’s dips of less lag

Sorry for the bump, but most games do hit detection on the client, so as to create a better user experience for the player using the weapon.
Latency is going to be a thing regardless of whether or not you do hit detection client-sided. The server has its own idea of where everyone’s character is positioned, so if a server-sided projectile hits a player, that player, on their screen, may have already moved out of the projectile’s path, but since the server still believes they were in the projectile’s path, they are damaged by it.