NumValue not subtractiing

I’m making a custom ammo system, and my ammo is defined as

local current_ammo = script.Parent.curam

But when I try referencing it, I get this error.
if reloading == false and current_ammo.Value > 0 then

1 Like

Is curam a NumberValue/IntValue? You could be referencing a different Instance if that’s the case

1 Like

Worse, the error says current_ammo is a number. I can’t make sense of how, if his script is correct, ‘curam’ could possibly be a number without getting curam is not a valid member of blah.

@telebama Are you sure you aren’t setting current_ammo anywhere else? Modifying it?

1 Like

Oh just do

if reloading == false and current_ammo > 0 then

Since ammo is a number, not an Int, there’s no need to index it with the .Value property it’s a primitive value

1 Like

Oh yikes my bad, I meant to say it’s a Numvalue

I am sure, and I meant to say it’s a num value.

1 Like

This fixed it, but the problem is the actual Value isn’t updating, and this is a serverside script image

1 Like

Use a changed function. It should update every-time the value changes.

1 Like

Oh alright, well it is because you’re changing the value of that variable (it is not a pointer or reference to what’s actually the value’s memory location, meaning the script) for that you’d have to do

script.Parent.curam.Value = current_ammo

for it to update the NumValue of the script (after modifying it)