I want to make it so that when you reload it only takes 25 of your max ammo.
Currently it usually works the first reload (not always) and then suddenly it will reload a 100 or more, or 50. I have no errors in the console. I have tried looking on the devforum but found nothing.
First Reload:
Then the second reload it did 25 again but then the third reload:
It took way more.
Reload Part:
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
if toolEquipped == true then
MouseHold2 = false
waist.C0 = waistC0
tool.ReloadEvent:FireServer()
aimTrack:Stop()
OTS_CAMERA_SYSTEM:Disable()
toolEquipped = false
reloadTrack:AdjustSpeed(tool.Configuration.ReloadTime.Value)
reloadTrack:Play()
wait(tool.Configuration.ReloadTime.Value)
toolEquipped = true
end
end
end)
Shoot part:
while true do
if MouseHold then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative
cam.CFrame = Camera.CFrame
waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(math.asin(Camera.CFrame.LookVector.Y)*1, 0, 0)
if MouseHold2 then -- the left mouse button
if player.PlayerGui.Ammo.Frame.Ammo.Text >= "1" then
if player.PlayerGui.Ammo.Frame.MaxAmmo.Text >= "1" then
tool.ShootEvent:FireServer(Mouse.Hit)
shootTrack:Play()
--if canShoot == true then
--canShoot = false
--local randomy = (math.random(0,strengthy*2)-strengthy)/1200
--game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame*CFrame.Angles(strengthx/360/2,randomy/4,0)
--wait(tool.Configuration.FireSpeed.Value)
--canShoot = true
--end
end
end
end
end
wait()
end
Server SCript I forgot to include:
tool.ReloadEvent.OnServerEvent:Connect(function(plr)
wait(tool.Configuration.ReloadTime.Value)
plr.PlayerGui.Ammo.Frame.Ammo.Text = 25
plr.PlayerGui.Ammo.Frame.MaxAmmo.Text = plr.PlayerGui.Ammo.Frame.MaxAmmo.Text - 25
end)