Code:
canrun = true
for i = 0, .4, .01 do --move door
local cframe = target.Parent.PrimaryPart.CFrame:lerp(destinationCFrame, i)
target.Parent:SetPrimaryPartCFrame(cframe)
if canrun then
if i >= .15 then
canrun = false
closeHandle(target) --FUNCTION
end
end
wait()
end -- end move
Here, I have a for loop that's supposed to move a door, using lerp. The door moving script runs fine without the function (labeled above in code). But when adding the function, the for loop pauses until the function is complete. This creates a pause of the door swinging open, as it pauses during its movement. All I need is to get the closeHandle() function to run if (i >= .15), without it pausing the for loop.

2 comments
try using spawn() to execute closeHandle on a different thread
Thank you for the answer.