I need help finding out a way to have the UIP event fire while the repeat loop is going.
Repeat Loop
function KnockDownCounterFunction()
repeat
print("CounterRunning")
KnockDownCount.Text = KnockCounter
wait(1)
KnockCounter = KnockCounter - 1
until KnockCounter == -1 or GetUp == true
if KnockCounter == -1 then
Players.LocalPlayer.PlayerGui.FightingHud.Knockdown.Visible = false
Players.LocalPlayer.PlayerGui.FightingHud.Hud.Visible = false
Players.LocalPlayer.PlayerGui.FightingHud.KnockDownCounter.Visible = false
game.ReplicatedStorage.FightingEvents.FightOverServerTrue:FireServer()
print("FiredServerFromClient")
end
end
UIP Event
UserInputService.InputBegan:Connect(function(input, event)
if input.KeyCode == Enum.KeyCode.Space and Knockdown == true and event == false and KnockTimePressed == false then
KnockTimePressed = true
KnockTimerTween:Pause()
if TimerBar.Position.X.Scale >= StartHit.X.Scale and TimerBar.Position.X.Scale <= EndHit.X.Scale then
print("TimedCorrectly")
KnockTimerTween:Cancel()
wait(1)
TimerBar.Position = UDim2.new(0, 0, 0, 0)
Anim:Stop()
GetUpAnim:Play()
GetUp = true
game.ReplicatedStorage.FightingEvents.KnockDownServerFalse:FireServer()
wait(1)
ThirdPerson()
wait(1)
WASDOn()
script.Parent.Humanoid.Health = script.Parent.Humanoid.Health + Regen
KnockTimePressed = false
Players.LocalPlayer.PlayerGui.FightingHud.Knockdown.Visible = false
Players.LocalPlayer.PlayerGui.FightingHud.KnockDownCounter.Visible = false
else
print("TimedBadly")
wait(1.5)
TimerBar.Position = UDim2.new(0, 0, 0, 0)
KnockTimerTween:Play()
wait(1.5)
KnockTimePressed = false
end
end
end)
Don’t worry about the ends I just took snippits of the code so you’re not looking at 450+ lines. This is a boxing game and when a fighter gets knocked down I use the repeat loop to countdown, a bar appears during the countdown which if you time correctly you get back up. The issue is once the countdown starts the game dosen’t register the spacebar input until after the count, I tested this by spamming space bar a bunch of times and the timed badly print didn’t show up or the timed correctly print, but asoon as the repeat loop ended it registered my input.
I tried using “spawn” to fire the function and also calling it straight up and neither worked.