give it a gun
local tool = script.Parent
local gunEvent = tool:WaitForChild("GunEvent")
local RunService = game:GetService("RunService")
local Handle = tool:WaitForChild("Handle")
local Reload = Handle:WaitForChild("Reload")
local Shoot = Handle:WaitForChild("Shoot")
local Empty = Handle:WaitForChild("Empty")
local muzzle = tool:WaitForChild("Muzzle")

local BULLET_SPEED = 100
local BULLET_LIFETIME = 5
local DAMAGE_BODY = 15
local DAMAGE_HEAD = 30
local COOLDOWN = 60 / 600
local RELOAD_TIME = 2.647

local defaultGrip = {
	Right = Vector3.new(0.040, 0.017, -0.999),
	Up = Vector3.new(-0.838, 0.544, -0.024),
	Forward = Vector3.new(-0.543, -0.838, -0.036),
	Pos = Vector3.new(0.248, -0.187, 0.009)
}

local reloadGrip = {
	Right = Vector3.new(0.040, 0.017, -0.999),
	Up = Vector3.new(-0.508, 0.861, -0.005),
	Forward = Vector3.new(-0.860, -0.508, -0.043),
	Pos = Vector3.new(0.101, -0.136, 0.004)
}

local function fromGripTable(grip)
	return CFrame.fromMatrix(grip.Pos, grip.Right, grip.Up)
end

local playerStates = {}

local function getState(player)
	playerStates[player] = playerStates[player] or {
		lastShot = 0,
		isReloading = false,
	}
	return playerStates[player]
end

local function addTrail(bullet)
	local att0 = Instance.new("Attachment", bullet)
	att0.Position = Vector3.new(0, 0, -bullet.Size.Z / 2)
	local att1 = Instance.new("Attachment", bullet)
	att1.Position = Vector3.new(0, 0, bullet.Size.Z / 2)

	local trail = Instance.new("Trail")
	trail.Attachment0 = att0
	trail.Attachment1 = att1
	trail.Lifetime = 0.3
	trail.Color = ColorSequence.new(Color3.fromRGB(255, 255, 100))
	trail.Parent = bullet
end

local function tweenGrip(fromGrip, toGrip, duration)
	local startTime = tick()
	while tick() - startTime < duration do
		if not tool:IsDescendantOf(game) then break end
		local alpha = (tick() - startTime) / duration
		tool.Grip = fromGrip:Lerp(toGrip, alpha)
		RunService.Heartbeat:Wait()
	end
	if tool:IsDescendantOf(game) then
		tool.Grip = toGrip
	end
end

local function createBullet()
	local bullet = Instance.new("Part")
	bullet.Size = Vector3.new(0.108, 0.118, 0.214)
	bullet.Color = Color3.fromRGB(248, 217, 109)
	bullet.Material = Enum.Material.DiamondPlate
	bullet.Anchored = true
	bullet.CanCollide = false
	bullet.CFrame = muzzle.CFrame
	bullet.Name = tostring(math.random() * 100)
	bullet.Parent = workspace
	return bullet
end

local function shootBullet(originCFrame, direction, character)
	local bullet = createBullet()
	bullet.CFrame = CFrame.new(originCFrame.Position, originCFrame.Position + direction)

	local startTime = tick()
	local lastPos = originCFrame.Position

	local rayParams = RaycastParams.new()
	rayParams.FilterDescendantsInstances = {character, tool}
	rayParams.FilterType = Enum.RaycastFilterType.Exclude

	local conn
	conn = RunService.Heartbeat:Connect(function()
		local elapsed = tick() - startTime
		if elapsed > BULLET_LIFETIME then
			bullet:Destroy()
			conn:Disconnect()
			return
		end

		local newPos = originCFrame.Position + direction.Unit * BULLET_SPEED * elapsed
		local rayResult = workspace:Raycast(lastPos, newPos - lastPos, rayParams)

		if rayResult then
			local hit = rayResult.Instance
			local target = hit:FindFirstAncestorOfClass("Model")
			local hum = target and target:FindFirstChild("Humanoid")

			if hum then
				if hit.Name == "Head" then
					hum:TakeDamage(DAMAGE_HEAD)
				else
					hum:TakeDamage(DAMAGE_BODY)
				end
			end

			bullet:Destroy()
			conn:Disconnect()
		else
			bullet.CFrame = CFrame.new(newPos, newPos + direction)
			lastPos = newPos
		end
	end)
end

local function resetGrip()
	tool.Grip = fromGripTable(defaultGrip)
end

tool.Equipped:Connect(resetGrip)
tool.Unequipped:Connect(resetGrip)

tool.AncestryChanged:Connect(function(_, parent)
	if not parent or not parent:IsDescendantOf(game.Players) then
		Handle.CanTouch = false
		if tool:FindFirstChild("Barrel") then tool.Barrel.CanTouch = false end
		if tool:FindFirstChild("Mag") then tool.Mag.CanTouch = false end
		task.delay(1.5, function()
			Handle.CanTouch = true
			if tool:FindFirstChild("Barrel") then tool.Barrel.CanTouch = true end
			if tool:FindFirstChild("Mag") then tool.Mag.CanTouch = true end
		end)
	end
end)

gunEvent.OnServerEvent:Connect(function(player, action, ...)
	local character = player.Character
	if not character then return end

	local state = getState(player)
	local ammo = tool:FindFirstChild("Ammo")
	local maxAmmo = tool:FindFirstChild("MaxAmmo")
	if not ammo or not maxAmmo then return end

	if action == "shoot" then
		local origin, direction = ...
		if typeof(origin) ~= "Vector3" or typeof(direction) ~= "Vector3" then return end
		if state.isReloading or tick() - state.lastShot < COOLDOWN then return end

		if ammo.Value <= 0 then
			Empty:Play()
		end

		if ammo.Value > 0 then 
		state.lastShot = tick()
		ammo.Value -= 1
		Shoot:Play()
		shootBullet(muzzle.CFrame, direction, character)
		end 
	elseif action == "reload" then
		if ammo.Value >= maxAmmo.Value or state.isReloading then return end

		state.isReloading = true
		tool.CanBeDropped = false
		tool.Enabled = false
		Reload:Play()

		task.spawn(function()
			tweenGrip(fromGripTable(defaultGrip), fromGripTable(reloadGrip), 0.25)
		end)

		task.delay(RELOAD_TIME, function()
			if ammo and maxAmmo then ammo.Value = maxAmmo.Value end
			task.spawn(function()
				tweenGrip(fromGripTable(reloadGrip), fromGripTable(defaultGrip), 0.25)
			end)
			tool.CanBeDropped = true
			tool.Enabled = true
			state.isReloading = false
		end)
	end
end)

use the gun script from here