wait doesn’t yield for an exact amount of time. When you use weight the program will basically take a break and then come back when it gets around to it after the time has expired. You are stacking the inaccuracies with a loop but if you just did a single wait(10) it would be reasonably close to 10. If you really wanted to loop in this sort of fashion though you could also do this.
Well my main goal is to lerp cframe a part using an easing module, this is my script for that:
local EaseModule = require(game.ReplicatedStorage.ease)
local cf = workspace.AAAA.AB.CFrame
local RunTime = 1/24
local Seconds = 10
local End = Seconds / RunTime
local Record = tick()
for i = 1, End do
local lerpValue = EaseModule.outSine(i, 0, 1, End)
script.Parent.AB.CFrame = cf:Lerp(script.Parent.B.CFrame, lerpValue)
print(tick() - Record)
And I want it to be exactly 10 seconds. I know I could use tweenservice, but that’s not what I want to achieve.
Tweenservice on the other hand takes exactly the time you want, and I was hoping this worked the same.
But “repeat wait(.1) until tick()-start>10” would be a “solution” for this?
If you dont actually need to wait(0.1) - say you are making a rendering engine with frames the industry standard is to create whats called a double buffer. assert each frame into a 2d matrix of colors then have the for loop update the colors with your calculation function, then update them with that data. Like in opengl that’d be like
glColor(1.0, 0.0, 0.0, 1.0); --this assigns what the color for all our indices in our color buffer will be
glClear(GL_COLOR_BUFFER_BIT) --actual for loop those values into the color buffer