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

Reload Script Help? [Not For Gun]

Asked by
KAAK82 16
10 years ago
local ammo = script.Parent:WaitForChild('Ammo')
local storedammo = script.Parent:WaitForChild('StoredAmmo')
sling = script.Parent:WaitForChild('Slingshot')

function Reload()
    if ammo.Value == 0 and storedammo.Value > 0 then
        ammo.Value = ammo.Value + 1
        storedammo.Value = storedammo.Value - 1
elseif
        storedammo.Value == 0 and ammo.Value == 0 then
        print('Out of Ammo!')
        ammo.Value = ammo.Value
    end
end

function Check()
    if ammo.Value == 0 and storedammo.Value == 0 then
        sling.Disabled = true
elseif
        ammo.Value > 0 or storedammo > 0 then
        sling.Disabled = false
    end
end

script.Parent.Equipped:connect(Reload)
script.Parent.Equipped:connect(Check)

it doesn't lower the Ammo to 0 after it's been thrown... (I have it in another Script) and so u can still Throw as much as u want, plz help!

1 answer

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
local ammo = script.Parent:WaitForChild('Ammo')
local storedammo = script.Parent:WaitForChild('StoredAmmo')
sling = script.Parent:WaitForChild('Slingshot')

function Reload()
    if ammo.Value == 0 and storedammo.Value > 0 then
        ammo.Value = ammo.Value + 1
        storedammo.Value = storedammo.Value - 1
    sling.Disabled = false
elseif
        storedammo.Value == 0 and ammo.Value == 0 then
        print('Out of Ammo!')
        sling.Disabled = true
    end
end

script.Parent.Equipped:connect(Reload)

I believe this should help you.

What I did was removed the check function and put it inside the reload function. What was happening is when it was equipt.. It would only check the once if they had ammo.. While if you put it along with the reload.. it will work every time they try to reload..

0
thnx, lol didn't notice that... KAAK82 16 — 10y
0
This works? lomo0987 250 — 10y
Ad

Answer this question