I’m gonna try that real quick.
You should be printing:
print(ammo.Value) now since you changed it.
You can make it easier to see in the printout by adding more to the print statement.
print(“AMMO =”, ammo.Value)
It’s still not working. By chance, this is optional, could I send you a copy of the game and see what’s wrong? I feel like that’d help, but it’s fine if not.
inserted at that point … and reload is also = to false in that script.
script.Parent.Handle.Shot:Play()
-----------
if ammo.Value == 0 then
reload()
end
-----------
RefreshGui()
You can put the gun in a separate file then save it, then upload it here.
How would I do this?
wasting characters so message sends
That is part of the code you posted with the
if ammo.Value == 0 then
reload()
end
added to it
idk why that is bold …
How would I put the gun into a file?
It won’t let me export it for some reason
You would need to either save a copy of your file and delete everything except the gun, or open two copies of Roblox.
Select the gun and right click. Select “copy”.
Go to the blank Roblox template and click on Workspace. Right click and select “Paste” or Past Into".
Play the workspace you just uploaded.
There is stuff that is missing. It shows up as RED in the output window.
Find the missing items and place them into your new file in the same location as they where in the old file.
Adding that now and I’ll send the file back
So it looks like you changed the reload function to this
local function reload()
if script.Parent.MaxAmmo.Value > (clipSize - script.Parent.Ammo.Value) then
reloadAnim:Play()
--script.Parent.Handle.Reload:Play()
--ammo = mag
canshoot = false
if script.Parent.MaxAmmo.Value > (clipSize - script.Parent.Ammo.Value) then
script.Parent.MaxAmmo.Value = script.Parent.MaxAmmo.Value - (clipSize - script.Parent.Ammo.Value)
script.Parent.Ammo.Value = clipSize
else
script.Parent.Ammo.Value = script.Parent.Ammo.Value + script.Parent.MaxAmmo.Value
script.Parent.MaxAmmo.Value = 0
end
RefreshGui()
wait(2.19)
canshoot = true
end
end
and the extra if statement that was added in is breaking it. Replace it with this:
local function reload()
reloadAnim:Play()
--script.Parent.Handle.Reload:Play()
--ammo = mag
canshoot = false
if script.Parent.MaxAmmo.Value > (clipSize - ammo.Value) then
script.Parent.MaxAmmo.Value = script.Parent.MaxAmmo.Value - (clipSize - ammo.Value)
ammo.Value = clipSize
else
ammo.Value = ammo.Value + script.Parent.MaxAmmo.Value
script.Parent.MaxAmmo.Value = 0
end
RefreshGui()
task.wait(2.19)
canshoot = true
end
I keep on changing it, it still won’t let me reload more than once.
Are you looking at the gui or the print() in the console? Because your gui is broken, even though the reload was working when i changed that function
At the current moment, the GUI is the least concerning. I want to make sure the gun can reload.
I have been over and over this reload function.
It is confusing.
One problem seems to be in the part where I have print(“2A”).
It is changing the MaxValue to be less than it was originally (30).
I made notes in the script to try and understand what is happening.
--=======
--NOTES:
--=======
--ammo = Instance | ammo = script.Parent.Ammo
--clipSize = Value | local clipSize = script.Parent.Ammo.Value
-- MaxAmmo = 30
-- Ammo = 30
-- Ammo.Value is decreased each time gun is fired (shots fired)
local function reload()
-- script.Parent.MaxAmmo.Value ==
print("CLIP SIZE =", clipSize)
print("AMMO VALUE", script.Parent.Ammo.Value)
-- if MaxAmmo is greater than shots fired, allow reload
if script.Parent.MaxAmmo.Value > (clipSize - script.Parent.Ammo.Value) then
print("1")
reloadAnim:Play()
--script.Parent.Handle.Reload:Play()
--ammo = mag
canshoot = false
-- if MaxAmmo is greater than remaining rounds
if script.Parent.MaxAmmo.Value > (clipSize - script.Parent.Ammo.Value) then -- (remaining rounds)
print("2A")
--MaxAmmo is now equal to MaxAmmo minus remaining rounds
script.Parent.MaxAmmo.Value = script.Parent.MaxAmmo.Value - (clipSize - script.Parent.Ammo.Value)
-- Reset Ammo.Value to original ammount
script.Parent.Ammo.Value = clipSize
else
print("2B")
-- Redefine Ammo.Value to be the sum of Ammo.Value and MaxAmmo.Value
script.Parent.Ammo.Value = script.Parent.Ammo.Value + script.Parent.MaxAmmo.Value
-- Set MaxAmmo to 0
script.Parent.MaxAmmo.Value = 0
end
print("3")
print()
RefreshGui()
wait(2.19)
canshoot = true
end
end
In the output, 2B doesn’t pop up