I will show the full code, however it is inside a tool if that helps.
local tool = script.Parent
local KOValue = "Kills"
local player = game:GetService("Players").LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")
local remoteFunction = replicatedstorage:WaitForChild("RemoteFunction")
local gungui = tool.Parent.Parent.PlayerGui:WaitForChild("gungui")
local ammo = gungui:WaitForChild("am")
local maxammo = gungui:WaitForChild("maxam")
local fetchBulletsLeft = replicatedstorage:WaitForChild("BulletsLeft")
local UIS = game:GetService("UserInputService")
local re = gungui:WaitForChild("reload")
local Bullet = replicatedstorage:WaitForChild("bullet")
local basepart = game.Workspace.Terrain
local bulletspeed = 500
local damage = 25
local FireRate = 0.1
local out = false
local attack = false
local ko = false
local function touching(hit)
local zom = hit.Parent.Name == "zombie"
if zom then
local zombie =hit.Parent.Zombie
wait()
if zombie.Health <= 0 and ko == false then
ko = true
local pla = game.Players:GetPlayerFromCharacter(tool.Parent)
pla.leaderstats[KOValue].Value = pla.leaderstats[KOValue].Value + 1
wait(0.1)
ko = false
end
end
end
tool.Activated:Connect(function(hit)
if out == false then
if attack == false then
attack = true
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local MouseHitLookVector = remoteFunction:InvokeClient(player)
local NewBullet = Bullet:Clone()
NewBullet.CFrame = tool.Handle.CFrame
NewBullet.Parent = game.Workspace
NewBullet.Velocity = MouseHitLookVector * bulletspeed
NewBullet.Touched:Connect(touching)
if ammo.Value > 0 then
ammo.Value -= 1
gungui.Currentammo.Visible = true
gungui.ammo.Visible = true
elseif maxammo.Value == 0 and ammo.Value == 0 then
out = true
else
re.Visible =true
out = true
gungui.Currentammo.Visible = false
gungui.ammo.Visible = false
end
wait(FireRate)
attack = false
basepart.Touched:Connect(function(lit)
if lit.Name == "bullet" then
wait(2)
lit:Destroy()
end
end)
end
else
UIS.InputBegan:Connect(function(key)
print("fuck my life")
if key == Enum.KeyCode.R then
if re.Visible == true then
re.Visible = false
wait(2)
ammo.Value = 25
maxammo.Value -= 25
out = false
end
end
end)
end
end)
thankyou for reading, i hope i can fix this :)

2 comments
it is not a local script, and i can't get mouse either, even though i can grab the local player
i found line 82 funny