How to figure out what is making my game lag

Whenever I test my game in studio it runs smoothly but when I publish the game and try it with a friend after a couple of minutes it starts to get really laggy. This is my first game and I am still somewhat new to scripting so I don’t know if I am doing certain things that create a ton of lag so is there any plugin or way to figure out what scripts might be causing lag.

We need more information on your game. Please tell us more information like what game is it, what you think might be causing the issue, etc.

There Could Be A Virus Or Bad Plugin. Check For Harmful Scripts Inside Of Each Model / File in the game Such As Vaccine, Big fires or other stuff

I am making a soccer game and I have a lot of Server to Client/ Client to Server Events.

How often are they firing? And how many are there?

You can try using microprofiler Microprofiler https://developer.roblox.com/en-us/videos/Introduction-to-the-Microprofiler

there are 10 different ones and one fires probably every couple of seconds

I don’t know enough information about your game but I would assume that it’s how much decoration you put around the game, like grass, trees, and parts. Too much models in the game can lag you. Maybe reduce the amount of models used. if that is however not the case then I can’t help much.

Yea I barely have any building at all, which is why I think it has something to do with my scripts

There might be a humanoid in the workspace.