While true loop isn't ending

I set this up to stop repeating after 10 seconds,

while jump == true do
	force.Force = Vector3.new(
		0,
			game.Workspace.Gravity * TotalMass * gravity_multiplier,
		0
	)
		wait(0.1)

	end
	wait(10)         <-----
	jump = false    <-----
	print("False")    <----- 
end)

“Print(“false”)” Never prints, and the loop doesn’t end. No errors or warnings and such. What am I missing?

that end in-between the vector3 and the wait(10) appears to be ending the while-do block

1 Like

That is intentional, I want the while-do block to loop until jump = false stops it

I suppose a better question is, How do I stop the while-do after 10 seconds?

Are you looking for something like this?

if jump == false then
  break
end
1 Like

the problem is that both the while loop and the jump = false are in the same thread. you can create a new thread for the while loop.

task.defer(function()
    while jump == true do
        force.Force = Vector3.new(
            0,
            game.Workspace.Gravity * TotalMass * gravity_multiplier,
            0
        )
        wait(0.1)
    end
end)

wait(10)
jump = false
print("False")
1 Like

I fixed it up a little, it should work now.

while jump == true do
        force.Force = Vector3.new(0, game.Workspace.Gravity * TotalMass * gravity_multiplier, 0)
        task.wait(10)
        jump = false
        print("False")
end
1 Like

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