local Players =game:GetService("Players")
local Remotes = script.Parent.Parent.Remotes
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Values = script.Parent.Parent.Values
--Remotes
local FireRemote = Remotes.Fire
local ReloadRemote = Remotes.Reload
--GunParts
local Gun = script.Parent.Parent
local FirePart = Gun:WaitForChild("FirePart")
--GunData
local MaxAmmo = Values.MaxAmmo
local Ammo = Values.Ammo
local StoredAmmo = Values.StoredAmmo
--Debug
CanFire = nil
if not Equp then
Gun.Equipped:Connect(function()
CanFire = true
print("Tool Equpied")
Mouse.Button1Down:Connect(function()
print(CanFire)
print("Fire")
if CanFire then
FireRemote:FireServer(FirePart.Position, (Mouse.Hit.p - Gun.Handle.CFrame.Position).unit * 300)
Ammo.Value = Ammo.Value - 1
end
if Ammo.Value <= 0 then
print("Reload")
ReloadRemote:FireServer(MaxAmmo, StoredAmmo)
end
end)
end)
end
Gun.Unequipped:Connect(function()
print("Uneq")
CanFire = false
end)
Any Advice on fixing this?