I require help with IntValue

So I got this thing, It’s supposed to make x thing transparent after the value goes down.
The problem is
Is that I have no idea of what the hell I am doing, and of course, the script won’t work.

How can I make it so X part becomes transparent after the value goes down?
image

1 Like

uhh
local AMMO = script.Parent.script.AMMO
local S = script.Parent.Parent.Parent.gun

script.Parent.script.AMMO:Changed()
if AMMO.Value < 8 then
S.Shel8.Transparency = 1
end
end

i dont know how changed() works

1 Like
local AMMO = script.Parent.script.AMMO
local S = script.Parent.Parent.Parent.gun
 
AMMO.Changed:Connect(function()
  if AMMO.Value < 8 then
    S.Shel8.Transparency = 1
  end
end)

This should work

script.Parent.script.AMMO

This suggests that ‘AMMO’ is the child of another script called “script” which is doubtful. Where is the AMMO value actually stored?

The Script in the first line is with a capital S, which indicates that it might be a container for scripted parts.

If not I would suggest OP using script.Ammo, since they go to the same path.

Well I just realized that they don’t go to the same path, if they did then it would be script.Parent.ammocheck.AMMO but instead its script.Parent.Script.AMMO

Where do you see the ammocheck part?

Edit. Oh correct. So it will for sure be a container if everything is set up properly.

1 Like

Since Changed passes the new number for an IntValue, you could use that to determine the transparency.

AMMO.Changed:Connect(function(CurrentAmmo)
    S.Shel8.Transparency = CurrentAmmo > 7
end)

Hmm. I should’ve shown the full thing, but I guess that’s just the embarrasement that I fell by using a free model (by “POOPENGUIN”), then asking for help on x thing in the devforums.

Ok, so this is the thing

Basically, I added a ammo feature to the thing, so it cannot fire if the value is 0.
It checks and subtracts ammo in the “Script”
And my intention was to make the shells go transparent within the “ammocheck” Script.

My apologies for not being clear early, is just that i’ve been banging my head into this for 2 hours

For your beginning script, that’s just so that if the ammo value is, let’s say, 7, it will run the code. So, you might want to do

if AMMO.Value < 1 then
S.Shel8.Transparency = 1
end

Also, if you want to constantly be checking the if statement, try using an infinite loop (like while true do, or something like that)

while true do
if AMMO.Value < 1 then
S.Shel8.Transparency = 1
end
end

I think that’s all I can do to help. Sorry!