Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Reload Script Help? [Not For Gun]

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

✓ Accepted answer
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..

2 comments

0

thnx, lol didn't notice that...

0

This works?

This discussion is preserved as it was. New answers, comments, and votes are closed.