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?
Hey fluffybuns,
I do believe your issue is that your script isn't noticing that val is below 30!
I experimented around a bit and I think this might do what you want. I'm not sure if you want the sound to be turned up every value of val or just once. I made this so it gets played once.
Hopefully, it does what you want! If not, let me know I'll look more into it!
Deathmatch7540
wait(2) print("ready") local bgm = script.Parent.chase local val = script.Parent.distanceval.Value local x = false bgm:Play() while x == false do if val < 30 then --If you want the sound to turn up at 30 then you should just add "=" print("less30") bgm.Volume = .5 wait(.2) x = true end end