Gun not reloading!

I’m trying to make it so that when you click R, it reloads your gun… The animation and sound plays, but it doesn’t actually fill the ammo back up to max ammo! I’ve tried using print to catch problems and it comes back showing as if i had never reloaded! Here is my code. Any help at all would be nice.

wait()--- Wait for everything to load!
---Variables
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local reload = char.Humanoid:LoadAnimation(script.Parent.Parent.Animations.Reload)
local idle = char.Humanoid:LoadAnimation(script.Parent.Parent.Animations.Idle)
local aim = char.Humanoid:LoadAnimation(script.Parent.Parent.Animations.Aim)
local mousedown = false
---Equipped
script.Parent.Parent.Equipped:Connect(function(mouse)
	idle:Play()
	--When button is released
	mouse.Button1Up:Connect(function()
		mousedown = false
		aim:Play()
		wait(3)
		if mousedown == false then
			aim:Stop()
			idle:Play()
		end
	end)
	---Reload
	uis.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.R then
			if script.Parent.Parent.Ammo.Value ~= script.Parent.Parent.MaxAmmo then
				script.Parent.Parent.Sounds.Reload:Play()
				reload:Play()
				wait(2)
				script.Parent.Parent.Ammo.Value = script.Parent.Parent.MaxAmmo.Value	
			end
		end
	end)
	---Fire!
	mouse.Button1Down:Connect(function()
		mousedown = true
		idle:Stop()
		if script.Parent.Parent.Ammo.Value > 0 then
			repeat	
				script.Parent.Parent.Events.Fire:FireServer(mouse.Hit.p)
				wait(.2)
			until mousedown == false or script.Parent.Parent.Ammo.Value <= 0
		end
	end)
end)

Is this a LocalScript?
(30 chars)

Yes It is a local script. (30 chars)

Your problem may be because you’re comparing a number value to an object.
image

It should be like this:

script.Parent.Parent.Ammo.Value ~= script.Parent.Parent.MaxAmmo.Value
3 Likes

Oh I totally missed that! I didn’t look close enough! Thanks a lot! :smiley:

1 Like