Repeat Until with two conditionals

I MADE a hold to M1 system,

local M1 = UIS.InputBegan:Connect(function(input, gpe)
	if not gpe and Can_M1 then
		if input.UserInputType == Buttons.MB1 or input.KeyCode == Buttons.Circle then
			repeat
			task.wait()
			local CanHit = CanHit()
			if CanHit and Can_M1 then
			InA:FireServer(0.5)
			Can_M1 = false
			local Current_Hit = os.clock()
			Ticks.LastHit = Current_Hit
			task.delay(1.8, function()
				if Ticks.LastHit == Current_Hit then
					Combo = 1
					print("combo reset")
				end
			end)
			
			
			local HitTrack = FXService.Animation(AnimationService[plrdata.CombatData.Weapon].M1Animations[Combo], humanoid)
			HitTrack:Play()
			
			HitTrack:GetMarkerReachedSignal("Contact"):Connect(function()
			MainCombat:FireServer("M1", Combo)
			end)
			
			if Combo ~= #AnimationService[plrdata.CombatData.Weapon].M1Animations then
			Combo += 1
			task.wait(0.5)
			Can_M1 = true
			else
			Combo = 1
			task.wait(1)
			Can_M1 = true
				end
			end
			until not UIS:IsMouseButtonPressed(Buttons.MB1) or not UIS:IsKeyDown(Buttons.Circle)
		end
	end
end)

While MouseButton1, or Circle is held down and conditions are met it SHOULD repeat right. It worked perfectly fine when I was only checking for MB1, but when I added Circle it just bugged.

Seems like you’re supposed to be using and.

2 Likes

No, I don’t assume so. If I use and, it’ll only register if I press both buttons, *which wouldn’t be logical,

It’s kind of confusing - you would have to check both conditions if they are both false.

Say you have MB1 active and Circle inactive, that would read it as not true or not false, passing the until condition and ending your repeat loop.

Switching it to and will read it as not true and not false, failing the until condition and continuing your repeat loop and will only pass if it is not false and not false.

In simpler terms: you are checking if either condition is met, not both (in this case, MB1 and Circle), and if even one of them is not being held down, it will break your loop.

2 Likes

Hold on you may be onto something let me check this out.

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