I'm trying to make it so when a guns ammo = 0, it makes the sound script for the gun disabled. Here is what I tried:
1 | if script.Parent.Ammo.Value < = 0 then |
2 | script.Parent.Sound.Disabled = true |
3 | end |
When I tested it, however, the script didn't disable.
Here I wrote a script for you!
1 | local ammo = script.Parent.Ammo |
2 |
3 | ammo.Changed:Connect( function () |
4 | if ammo.Value < = 0 then |
5 | script.Parent.Sound.Disabled = true |
6 | end |
7 | end ) |
Now the fun part of reading over the code and seeing what it does!
Line 1 - Referencing the ammo Boolean.
1 | local ammo = script.Parent.Ammo -- Referencing the Boolean |
Line 3 - 7 -- Checking if ammo under number then disabling.
1 | ammo.Changed:Connect( function () ---- Creates a function when ammo value changed. |
2 | if ammo.Value < = 0 then --- Checks if the value is equal to or under '0' |
3 | script.Parent.Sound.Disabled = true --- If it is it will disable your "Sound" script. |
4 | end --- Closes if statement |
5 | end ) -- Closes function. |
Hope you enjoyed the script! - DrShockz :)