local num = workspace.Number.Value -- 1 second
while task.wait(num) do
print("hi")
end
lets say that I changed the num value using other script (for ex.: player touched a part and the num increased by 1), and inside the while loop it hadnt changed, still at 1 print per second.
Using a variables stores the value of it at the particular instant, so even if you change the value the ‘num’ variable will still be equal to 1. To fix this, simply wait the num value instead of the variable
while task.wait(workspace.Number.Value) do
print("hi")
end
So it will wait the updated value if you change it