In a script, I have a number value that constantly changes. However, when the value reaches below 30, the script does not make the changes shown
wait(2)
print("ready")
local bgm = script.Parent.chase
local val = script.Parent.distanceval.Value
bgm:Play()
while val < 30 do
print("less30")
bgm.Volume = .5
wait(0.2)
end
Instead of changing the volume and printing, it does nothing. Why does it do this and how can I fix it?

2 comments
Are you sure it's never going over thirty at any point in time? Does the output print any errors?
No errors. It only checks when the game begins, so if I set the value to less than 30 before I test the game, the script works. However, anything after that does not work.