local hyperActivate = game:GetService("ReplicatedStorage"):WaitForChild("HyperActivate")
hyperActivate.OnServerEvent:Connect(function(plr)
plr:FindFirstChild("Hyper"):FindFirstChild("HyperActive").Value = true
while task.wait(1) and plr:FindFirstChild("Hyper").Value > 0 do
plr:FindFirstChild("Hyper").Value -= 5
end
plr:FindFirstChild("Hyper"):FindFirstChild("HyperActive").Value = false
end)
at “until plr:FindFirstChild(“Hyper”).Value == 0” it means that whenever it reaches 0, loop will stop, in this case it won’t work how you think it will, just simply change == to <=
The reason why it doesn’t stop is, because you want it only to end if it as 0.
If the Hyper Value would be 6, then it would go into negative so -4.
The programming uses logical math, to ignore the fact that it is in the negative you do <=, what this exactly do is that it is “Under or equal”. Having only “<” would ignore the 0 and stop only at -1.
== - Equal to
< - Smaller than
> - Bigger than
<= - Smaller than or equal to
>= - Bigger than or equal to
~= - Is not equal to
*=, += and -= means like when trying to do something on numbers you dont need to extra put the number which should get subtracted. So if Value = 5 then it would work like that Value -= 1 will be 4 instead of writing Value = Value - 1
You most likely subtract the value when it is below 5, making it go below 0 and therefore, not being equal to 0, causing the repeat to not stop
repeat
task.wait(1)
if plr:FindFirstChild("Hyper").Value > 5 then -- if the value is above 5
plr:FindFirstChild("Hyper").Value -= 5 -- subtract by five
else -- if it isnt above 5 (meaning it is less than 5)
plr:FindFirstChild("Hyper").Value = 0 -- then just make it to 0
until
plr:FindFirstChild("Hyper").Value == 0 -- it is now 0, so the loop stops
could be written differently, just formatted it this way to keep it a repeat until loop