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