How can I find out which part of my script is lagging?

I have a script with a lot of lines and I was wondering if there was any way to pin point which exact part of the script is causing the lag? Any and all help is appreciated.

2 Likes

You could add print commands every few lines of code or so, if a long period of time passes between two print commands then you know that the code in between those two print commands is causing the lag.

1 Like

Try to use the print() to figure out which part sends an error and attempt to fix it.

1 Like

Hiya.

Many different debugging features are included within the Roblox Lua Scripting Language.

A specific and easy to use one is print.

Simple, if the statement has the output of what you printed, you know that the code is running. For example:

if player.Name == "YourName" then
print("Woah! It's them!!!")
end

Other options are using pcalls to catch errors, alongside many other debugging features, all included within the Roblox API site.

1 Like

All my code runs fine the issue is that a certain part of my code causes massive server lag. I’m trying to find which part is causing the lag so I can fix it.