Repeat...Until help

how would i set

player.Character.Humanoid.ragdoll.Value = true to false after the loop is done?

what i mean is:

i have a loop that checks if something is above a certain value, if it is i want to set the ragdoll value to false.

would this work?

	local passedOut = false
	magic.Value.Changed:Connect(function()
		if magic.Value < 150 and passedOut == false then
			passedOut = true
			game.ReplicatedStorage.Message:FireClient(player, "You have passed out due to exhaustion.")
			player.Character.Humanoid.ragdoll.Value = true
			
			repeat
			wait()
			until magic.Value > 150
			player.Character.Humanoid.ragdoll.Value = false

Think of a repeat until loop as the opposite of a while loop, if a while loop is checking if a condition is true, then a repeat until loop will repeat until the condition is false

while Condition == true do
end


repeat
until Condition == false
1 Like

You’d make an if statement when the value of magic is greator than 150.

Try this:

local passedOut = false
	magic.Value.Changed:Connect(function()
		if magic.Value < 150 and passedOut == false then
			passedOut = true
			game.ReplicatedStorage.Message:FireClient(player, "You have passed out due to exhaustion.")
			player.Character.Humanoid.ragdoll.Value = true
			
			repeat
			wait()
			until magic.Value > 150
            print(magic.Value)
            
         if magic.Value > 150 then
			player.Character.Humanoid.ragdoll.Value = false
         end

Untested but it seems like it would work.

1 Like

this doesn’t really help me

i want to know if the loop would work,

when the magic value is over 150, would the ragdoll value be set to false?

Looking at the loop, you are yielding the code until the value is greater so it appears so, but add an if statement just to be sure as @ValiantWind put in his code

1 Like

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