I made this script as a simple lift, but it randomly stops moving halfway through until the third time around, where it works fully. Here is the script:

script.Parent.Touched:connect(function(plr)
	if plr.Parent ~= nil then
	local h = plr.Parent:findFirstChild("Humanoid")
		if h ~= nil then
			h.Parent.Torso.Anchored = true
			for i = 1, 90 do
			h.Parent.Torso.CFrame = h.Parent.Torso.CFrame + Vector3.new(0,0.3,0)
			wait(0.000001)
			end
			wait(0.5)
			h.Parent.Torso.Anchored = false
		end
	end
end)

Does anyone know why?