Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change the integer?

Asked by
painzx3 43
9 years ago

This is the part of a gun script made by XAXA that I'm editing so that whenever a StringValue named "Magazine[5.56x45]" is retrieved from a storage box and relocated into a player's backpack the script will essentially utilize the "findFirstChild" function and if the said stringvalue is found I want it to add "1" to the "MagazinesCarried".

MagazinesCarried = 1 --There is no "StoredAmmo" or "Ammo" Numbervalues within the tool,  if the StringValue is found then I want it to add 1 to the current value.
--After the mag is retrieved nothing happens and no errors presented--
function ammAdd()
    local mag = tool.Backpack:findFirstChild("Stanag30") 
    if mag ~= nil then
    local ammo = MagazinesCarried + 1
    script.Parent.Parent.Stanag30:remove()  
    end
end

function updateHUD() -- INDEX: F-UPDTH ... Updates the HUD whenever the gun is reloaded or equipped. Uses F-UPDTA to update ammo.
    Hud.ModeLabel.Text = (fireModeValues[fireMode])
    if usesClips then
        Hud.MagazinesCarriedLabel.Text = "x "..MagazinesCarried
    else
        Hud.MagazinesCarriedLabel.Visible = true
        Hud.ClipPic.Visible = true
    end
    Hud.AmmoMaxLabel.Text = tostring(AmmoMax)
    updateAmmo()
end

Answer this question