Hi, I’m looking for advice on optimizing Luau code for Roblox. I’ve been working on a few projects, and some of the areas with the most code are performing slower. Just not sure what exactly I’m trying to optimize at this point.
While my projects are becoming larger iin size, I’m experiencing slowdowns in the regions with loops, event listeners, or many service calls. Though I have some tips in my bag, I’m still not aware of how to implement them in a practical project.
I’ve tried a few common optimization techniques like caching services to avoid repeated calls, and reducing the number of FindFirstChild checks inside loops. I’ve also been more mindful about when to use wait() in loops. But I feel like I could be doing more to improve the overall performance.
Example:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
for _, player in ipairs(Players:GetPlayers()) do
if player == localPlayer then
-- idk do something specific
end
end
Any tips and tricks would be really helpful :}