How can I make the remoteEvent fire for only the localPlayer, it fires for all players instead

local tool = script.Parent
local hitboxSize = Vector3.new(5, 1, 5)
local damageEvent = game.ReplicatedStorage.Events.DamageEvent

local damageAmount = 5
local humanoidAttacker = game.Players.LocalPlayer.Character

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
local humanoid = character:WaitForChild(“Humanoid”)

local anim = tool.SwordAnimations:WaitForChild(“Block”)
local animator = humanoid:FindFirstChildOfClass(“Animator”)

local function SwordSlashes()
local numSlashes = 0
local lastSlashTime = tick()
local slashCooldown = 0
local isPlayingAnimation = false

local function Slash()
if numSlashes >= 5 or isPlayingAnimation then
return
end

local timeSinceLastSlash = tick() - lastSlashTime
if timeSinceLastSlash < slashCooldown then
	return
end

if timeSinceLastSlash > 2 and numSlashes > 0 then
	numSlashes = 0
	wait(3)
end

local slashAnimName = "Slash" .. (numSlashes + 1)
local slashAnim = tool.SwordAnimations:WaitForChild(slashAnimName)
local slash = animator:LoadAnimation(slashAnim)

if not isPlayingAnimation and not slash.IsPlaying then
	isPlayingAnimation = true
	slash:Play()
	slash:AdjustSpeed(1.3)
	slash.Stopped:Wait()
	numSlashes = numSlashes + 1
	lastSlashTime = tick()
	isPlayingAnimation = false

	local hitbox = Instance.new("Part")
	hitbox.Name = "Hitbox"
	hitbox.Anchored = true
	hitbox.Size = hitboxSize
	hitbox.CanCollide = false
	hitbox.Transparency = 0.5
	hitbox.CFrame = humanoidrootpart.CFrame * CFrame.new(0, 0, -3)
	hitbox.Parent = workspace

	for _, humanoid in ipairs(workspace:GetDescendants()) do
		if humanoid:IsA("Humanoid") and humanoid.Parent ~= character then
			local distance = (humanoid.RootPart.Position - hitbox.Position).Magnitude
			if distance < hitboxSize.magnitude / 2 then
				damageEvent:FireServer(humanoid, damageAmount, humanoidAttacker)
			end
		end
	end

	hitbox:Destroy()
end

end

spawn(function()
	while true do
		wait(0.1)
		local timeSinceLastSlash = tick() - lastSlashTime
		if timeSinceLastSlash > 1 and numSlashes > 0 then
			numSlashes = 0
		end
	end
end)

return Slash

end

local slashAction = SwordSlashes()
tool.Activated:Connect(slashAction)

First of all, please embed your code into three backticks (`). This will create something like this:

print("Hello world")

or just press CTRL+E or click the preformatted text image button in the post creator window.

If you want it to fire only to a certain player, you should use BindableEvents.

I did try using Bindablevents that didnt quite work