Stop Move To if

Hey.
I’m trying to stop the MoveTo() if the while cycle has ended before the dummy has arrived to the destination.

The script is the following:

Dummy.Humanoid:MoveTo(Vector3.new(
		Finish:GetPivot().X,
		Finish:GetPivot().Y,
		Finish:GetPivot().Z
))
	
while Temp >= 0 do
	Temp = Temp - Calc
		
	if Temp < 0 then
		Temp = 0
		State:SetAttribute("Energy", Temp)
	else
		Temp = Temp - Calc
		State:SetAttribute("Energy", Temp)
	end
	wait(1)
end

--Stop it here 

I’ve tried searching around but i found nothing.
I’ve tried making the dummy move to another position, but it doesn’t work.

You’re setting Temp to 0 if Temp is below 0, so your while loop will go on forever. Consider breaking the loop or using while Temp > 0 instead

ah sh- i feel stupid.
Thank you a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.