Hello so i've had this issue for a while now and i can't find any way to fix it. Heres the script:
LocalScript:
--Example local function getProp(obj, prop) local getPropVar = obj[prop] return getPropVar end local protectedCall = pcall while wait() do for i,v in next, game:GetDescendants() do local Transparency = protectedCall(function() getProp(v, "Transparency") end) --Im guessing pcall is the part that lags but im not sure if Transparency then Transparency = 1 end end end
The script works prefectly fine but it causes alot of lag. Try it out for yourself and if you find a fix that you would like to share, please tell me.
Any help is appreciated.
While loop is a bad practice for running something repeatedly, it doesn't run based on the client FPS and it's very performance-consuming. To fix this lag, RunService.RenderStepped event will do the job. If you don't know what's RenderStepped, RenderStepped is fired every time a frame is rendered. So using RunService.RenderStepped is a good practice to run something repeatedly based on the client FPS. (Correct me if I'm wrong lol)