The reloading part doesn't work. It's on line 55. What it's supposed to do is that Bullets.Value will be equal to MaxBullets.Value. However, it doesn't refill it to that value and stays the same. Help! There's no errors either.
--//Variables local Tool = script.Parent.Parent local ScriptsFolder = Tool.Scripts local AnimationsFolder = Tool.Animations local SettingsFolder = Tool.Settings local HoldAnimation = AnimationsFolder:WaitForChild("HoldAnimation") local ReloadAnimation = AnimationsFolder:WaitForChild("ReloadAnimation") local Handle = Tool.Handle local GunfireSound = Handle.FireSound local ReloadSound = Handle.ReloadSound local Player = game:GetService("Players").LocalPlayer local Mouse = Player:GetMouse() local RemoteEvents = game:GetService("ReplicatedStorage").RemoteEvents local PlayAnimation = RemoteEvents.PlayAnimation local StopAnimation = RemoteEvents.StopAnimation local CreateBullet = RemoteEvents.CreateBullet local Reloading = false local Debounce = false local Equipped = false --//Settings Variables local FiringRate = SettingsFolder:WaitForChild("FiringRate") local Bullets = SettingsFolder:WaitForChild("Bullets") local MaxBullets = SettingsFolder:WaitForChild("MaxBullets") local Accuracy = SettingsFolder:WaitForChild("Accuracy") local Damage = SettingsFolder:WaitForChild("Damage") --//Events Tool.Equipped:Connect(function() PlayAnimation:FireServer(HoldAnimation) Equipped = true end) Tool.Unequipped:Connect(function() StopAnimation:FireServer(StopAnimation) Equipped = false end) Tool.Activated:Connect(function() if Debounce == false then Debounce = true Shoot() wait(FiringRate.Value) Debounce = false end end) function Shoot() if Bullets.Value > 0 and Reloading == false and Equipped == true then local ray = Ray.new(Handle.CFrame.p, (Mouse.Hit.p - Handle.CFrame.p + Vector3.new(math.random(0-Accuracy.Value,Accuracy.Value),math.random(0-Accuracy.Value,Accuracy.Value),0)).unit * 300) local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true) CreateBullet:FireServer(Tool,position,part,Damage.Value) Bullets.Value = Bullets.Value - 1 GunfireSound:Play() end end function onKeyPress(actionName, userInputState, inputObject) --This is the reload part. if userInputState == Enum.UserInputState.Begin and Reloading == false then Reloading = true PlayAnimation:FireServer(ReloadAnimation) ReloadSound:Play() wait(3) Bullets.Value = MaxBullets.Value Reloading = false end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)