How to use Raycast Hitbox Module Serversided?

Raycast Module I am talking about: Raycast Hitbox 4.01: For all your melee needs!

So I am trying to make a Sword that, when activated, fires a Remote Event that activates a script using the Raycast Module. I am having a lot of trouble with trying to figure out how to do this.

Here are my current scripts:
LOCAL SCRIPT

mouse = Player:GetMouse()

mouse.Button1Down:connect(function()
	game.ReplicatedStorage.SwordTesting:FireServer("Activate")
	wait(0.05)
end)

SERVER SCRIPT

local RaycastHitbox = require(game.ServerStorage.RaycastHitboxV2)
game.ReplicatedStorage.SwordTesting.OnServerEvent:connect(function(Player, Action)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = Character:WaitForChild("Sword")	
	
local Hit = false
	
	
Hitbox = RaycastHitbox:Initialize(Tool, {Character})
Hitbox:PartMode(false)	
Hitbox:DebugMode(true)
		
if Action == "Activate" then
		Hitbox:HitStart()
		
		local HitboxConnection 
		HitboxConnection = Hitbox.OnHit:Connect(function(hit, humanoid)
			print(humanoid.Parent.Name)
			humanoid:TakeDamage(20)
			Hitbox:HitStop()
			HitboxConnection:Disconnect()
			Hit = true
		end)
		
		wait(1)
		if Hit == false then
			Hitbox:HitStop()
			HitboxConnection:Disconnect()
		end
	end
end)

These scripts work as intended and do function but I know this method I am using isn’t the most optimal way to do this. For example, every, single time I use the Tool, it fires the event and does

Hitbox = RaycastHitbox:Initialize(Tool, {Character})

The reason I have that line inside of the remote event is because I just don’t know a better way to do it since I don’t know another way to get the player’s character in a Server Script, besides from the OnServerEvent’s Parameters.

I’ve tried a multitude of attempts and debugging to get this to work, but I just can’t seem to get it to work properly.
Can someone please help me learn what I am doing wrong and the correct way to use this module on the Server?

I ended up editing the script a bit so now Hitbox = RaycastHitbox:Initialize(Tool, {Character}) only fires on Tool Equip

local RaycastHitbox = require(game.ServerStorage.RaycastHitboxV2)

game.ReplicatedStorage.SwordTesting.OnServerEvent:connect(function(Player, Action)
	
	
if Action == "Equip" then
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = Character:WaitForChild("Sword")	
		
Hitbox = RaycastHitbox:Initialize(Tool, {Character})
Hitbox:PartMode(false)	
Hitbox:DebugMode(true)
end
	
	
if Action == "Activate" then
		local Hit = false
		Hitbox:HitStart()
		
		local HitboxConnection 
		HitboxConnection = Hitbox.OnHit:Connect(function(hit, humanoid)
			print(humanoid.Parent.Name)
			humanoid:TakeDamage(20)
			Hitbox:HitStop()
			HitboxConnection:Disconnect()
			Hit = true
		end)
		
		wait(1)
		if Hit == false then
			Hitbox:HitStop()
			HitboxConnection:Disconnect()
		end
	end
end)

But there is another problem I am facing, for some reason there are random “ghost rays” from the last OnHitConnection if you reactivate the tool too fast, but I am not sure how to solve this beside just adding a cooldown to the tool.

Here is how it is supposed always work: https://gfycat.com/physicalidolizedafghanhound

But then it does this if you reactivate too fast: https://gfycat.com/giddyearnestavocet
Those two ghost rays also do damage if something is being hit by them.

It could be that you’re starting a hit again before cancelling the previous one. When you press quickly it’ll call HitStart several times and if you don’t make sure the previous hit is complete or cancelled it might cause problems as you’d call HitStart twice or more in a row.

That’s what I was thinking but the connection theoretically should be stopped and reset once it hits something.

		local HitboxConnection 
		HitboxConnection = Hitbox.OnHit:Connect(function(hit, humanoid)
			print(humanoid.Parent.Name)
			humanoid:TakeDamage(20)
			Hitbox:HitStop()
			HitboxConnection:Disconnect()
			Hit = true
		end)

I know that it has to do with the Hitbox:HitStop() and HitboxConnection:Disconnect() in this function since when I was testing the script without those two, it didn’t have the ghost rays problem. The thing is, I don’t know another way for me to be able to stop casting the rays once it hits something without a HitStop() in the OnHit function.

EDIT: For example this script without the Hitbox:HitStop() and HitboxConnection:Disconnect() doesn’t suffer from the ghost ray problem at all

local RaycastHitbox = require(game.ServerStorage.RaycastHitboxV2)

game.ReplicatedStorage.SwordTesting.OnServerEvent:connect(function(Player, Action)
	
	
if Action == "Equip" then
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = Character:WaitForChild("Sword")	
		
Hitbox = RaycastHitbox:Initialize(Tool, {Character})
Hitbox:PartMode(false)	
Hitbox:DebugMode(true)
end
	
	
if Action == "Activate" then
		local Hit = false
		Hitbox:HitStart()
		
		local HitboxConnection 
		HitboxConnection = Hitbox.OnHit:Connect(function(hit, humanoid)
			print(humanoid.Parent.Name)
			humanoid:TakeDamage(20)
		end)
		
		wait(1)
		Hitbox:HitStop()
		HitboxConnection:Disconnect()
	end
end)

But this can damage multiple people, I’m trying to figure out how to make it so it will only damage the first entity hit.