Hello, Everytime the Server receives the Remote Event it is supposed to subtract from the Number Value in the script named “Ammo” until it gets to 0. Instead, when it prints the ammo value it keeps printing 29 (max ammo is 30). I’m not sure why it isn’t working thanks for any help.
local rep = game:GetService("ReplicatedStorage")
local tool = script.Parent
local remoteEvent = game.ReplicatedStorage["Weapon RemoteEvents"]["STAR-TR"]
characther = nil
remoteEvent.OnServerEvent:Connect(function(plr, mousePos, plrStrength)
local ammo = plr.Character:FindFirstChildWhichIsA("Tool"):FindFirstChild("CurrentAmmo").Value
if ammo >= 1 then
ammo = ammo - 1
print(ammo)
characther = plr.Character or plr.CharacterAdded:Wait()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {tool, characther, tool.Model:GetChildren(), tool.Handle}
behavior.RaycastParams = params
behavior.Acceleration = Vector3.new(0, gravity, 0)
behavior.AutoIgnoreContainer = true
behavior.CosmeticBulletTemplate = ball
behavior.CosmeticBulletContainer = workspace.AvailableDodgeballs
local pos = tool.Handle.CFrame * CFrame.new(0,0,-50)
local direction = (mousePos - tool.Handle.Position).Unit
caster:Fire(tool.Handle.Attachment.WorldPosition ,direction, speed, behavior)
end
end)
-- There is more code but I omitted it let me know if you need it