Task.wait() migration runs better in studio than actual game

I migrated some of my systems (uppertorso following camera, visual gun stuff) from wait() to task.wait(), and I see an improvement in Studio, but when I actually playtest the game, it runs really, really bad. My assumption is that I didn’t adjust the numbers I put into the wait()s for task.wait(), but that shouldn’t be the same case for my torso camera script which only used near-instant “wait()” before the migration without any number value and should run fine with task.wait()s. I’ll provide code if needed. Help?

Edit: I’ve noticed how wait() runs better even with high ping but is sometimes inconsistent, while task.wait() is super dependent on ping

Hmm, the timings can be different with task.wait but it almost sounds like you have stuff that should be hooked up to something like RunService’s Heartbeat event

You should check the Microprofiler to see for sure where you are losing frames. Realistically, task.wait won’t magically give you better performance. It can make your code run more often than wait would, so if your code is slow, it will exacerbate that.

This is visual maybe try

local rns = game:GetService("RunService")

rns.Stepped:Wait()