Ammo System Not Working

Hi! So I am creating an Ammo system and it is not functioning correctly. No ammo is being deducted. Here is my code:

function module:CreatePlayer(plr)
	local newPlayerFolder = Instance.new("Folder")
	newPlayerFolder.Name = plr.UserId
	newPlayerFolder.Parent = script.Parent.Players

	local newPlayerHealthValue = Instance.new("IntValue")
	newPlayerHealthValue.Name = "Health"
	newPlayerHealthValue.Value = 100
	newPlayerHealthValue.Parent = newPlayerFolder
	
	local newPlayerHealthValue = Instance.new("IntValue")
	newPlayerHealthValue.Name = "Primary1Ammo"
	newPlayerHealthValue.Value = 31
	newPlayerHealthValue.Parent = newPlayerFolder
	
	local newPlayerHealthValue = Instance.new("IntValue")
	newPlayerHealthValue.Name = "Primary2Ammo"
	newPlayerHealthValue.Value = 8
	newPlayerHealthValue.Parent = newPlayerFolder
	
	local newPlayerHealthValue = Instance.new("IntValue")
	newPlayerHealthValue.Name = "SecondaryAmmo"
	newPlayerHealthValue.Value = 12
	newPlayerHealthValue.Parent = newPlayerFolder

	print("Player "..plr.Name.."'s folder has been setup! ("..plr.UserId..")")
	
	return true
end

function module:UpdateAmmo(plr, gunType, amount)
	print("Updating Ammo (Removing "..amount.." ammo)")
	local playerFolder = script.Parent.Players[plr.UserId]

	if playerFolder == nil then
		print("Invalid Player")
		return false
	end

	if gunType == "prim1" then
		local ammo = playerFolder["Primary1Ammo"].Value
		ammo -= amount
		print("New Ammo: "..ammo)
		return ammo
	elseif gunType == "prim2" then
		local ammo = playerFolder["Primary2Ammo"].Value
		ammo -= amount
		print("New Ammo: "..ammo)
		return ammo
	elseif gunType == "second" then
		local ammo = playerFolder["SecondaryAmmo"].Value
		ammo -= amount
		print("New Ammo: "..ammo)
		return ammo
	end
end

Hello! Is there anything, other than the “Updating Ammo”, line being printed to the output?
I’m assuming it’s not a mismatch of arguments considering you are printing the amount.

A cause I can imagine here could be the value of gunType.
Try adding print("Gun Type:", gunType) after the line printing “Updating Ammo”.

Hey did you figure anything out? Still needing help.

Is this just a case of you not updating your GUI to the new ammo amount?

No, the GUI isn’t the issue. The value isn’t changing what so ever. The new ammo always stays 30.

Whenever I experienced issues like you are, I would usually put local Ammo = location then use ammo.Value if that makes sense.

You’re doing what is known as indirect changing. An example of this is …

local x = 0 
local y = x 
y += 1 
print(x) --> This is still 0, since the code is changing the value of y.

--[[
You are currently creating a variable containing the value of ammo. 
Not a reference to the property.
--]]

This only changes the variable’s value. Instead you need to do the following…

local ammo = playerFolder["Primary1Ammo"]
ammo.Value -= 1
print("New Ammo: " .. ammo.Value) 
return ammo.Value

Hope this helped. If there is any further issue with this, do not hesitate to let me know!