So in my game theres a certain round that will spawn different types of enemie, and when they spawn in they add +1 to the value "DogsLeft". When they die they subtract the "DogsLeft" value by -1. So i made this script so when theres 1 zombie left, it enables other scripts within the model. heres the code:
while true do
wait(0.1)
if game.ReplicatedStorage.Values.DogsLeft.Value == 1 then
script.Parent.Drop4.Disabled = false
script.Parent.Death2.Disabled = false
script.Parent.Death.Disabled = true
else
--print "dog round still active"
end
end
so it works fine, but i really don't like having a script loop 0.1 seconds, but the issue is if i have it at 1 or 2 seconds, it'll cause a problem where if the final enemies are being killed and the script hasnt looped, it wont enable the scripts because the script would read the value as jumping from (for example) 3 to 0 within those 1 - 2 seconds, skipping the values between
is there a better way to loop this script? or a different way to loop scripts?

1 comment
use RenderStepped, it runs on every frame