Tool counts as hitbox?

It’s hard to explain so here’s a video of what I’m dealing with:
https://gyazo.com/6a69be3924e15c68c4282a934e45ae4b

My script:

local RaycastHitbox = require(game:GetService("ReplicatedStorage").Modules.RaycastHitboxV4)

function Create(ty)
	return function(data)
		local obj = Instance.new(ty)
		for k, v in pairs(data) do
			if type(k) == 'number' then
				v.Parent = obj
			else
				obj[k] = v
			end
		end
		return obj
	end
end

local Services = {
	Players = (game:FindService("Players") or game:GetService("Players")),
	TweenService = (game:FindService("TweenService") or game:GetService("TweenService")),
	RunService = (game:FindService("RunService") or game:GetService("RunService")),
	Debris = (game:FindService("Debris") or game:GetService("Debris")),
	ReplicatedStorage = (game:FindService("ReplicatedStorage") or game:GetService("ReplicatedStorage")),
	Lighting = (game:FindService("Lighting") or game:GetService("Lighting")),
	ServerScriptService = (game:FindService("ServerScriptService") or game:GetService("ServerScriptService"))
}

local Tool = script.Parent
Tool.Enabled = true

local Handle = Tool:WaitForChild("Handle")
local Hitbox = RaycastHitbox.new(Tool:WaitForChild("Handle").Hitbox)

--[[local SwordMesh = Handle:WaitForChild("SwordMesh")
SwordMesh.VertexColor = Vector3.new(1,1,1) -- Keep it normal]]

local Properties = {
	Damage = 14,
}

local Sounds = {
	Lunge = Handle:WaitForChild("Lunge"),
	Unsheath = Handle:WaitForChild("Unsheath")
}

local Remote = Tool:FindFirstChildOfClass("RemoteEvent") or Create("RemoteEvent"){
	Name = "Remote",
	Parent = Tool
}

local MousePos = Tool:FindFirstChildOfClass("RemoteFunction") or Create("RemoteFunction"){
	Name = "MouseInput",
	Parent = Tool
}

local Attacking = false
local Shoving = false
local db = false

function IsInTable(Table,Value)
	for _,v in pairs(Table) do
		if v == Value then
			return true
		end
	end
	return false
end

local function Wait(para) -- bypasses the latency
	local Initial = tick()
	repeat
		Services.RunService.Stepped:Wait()
	until tick()-Initial >= para
end

function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end



local MouseHeld = false
local CurrentMotor,RightWeld,Part0,Part1
local EquippedEvents = {}

local Player,Character,Humanoid,Root

function Equipped()
	Character = Tool.Parent
	Player = Services.Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
	Root = Character:WaitForChild("HumanoidRootPart")
	
	if not Humanoid or Humanoid.Health <= 0 then return end
	
	Animations = Tool:WaitForChild("Anims")
	Animations = {
		Stab = Humanoid:LoadAnimation(Animations:WaitForChild("StabAnim")),
		Charge = Humanoid:LoadAnimation(Animations:WaitForChild("ChargeAnim"))
	}
	Touch = Handle.Touched:Connect(function(hit)
		if not hit or not hit.Parent then return end
		local Hum,FF = hit.Parent:FindFirstChildOfClass("Humanoid"),hit.Parent:FindFirstChildOfClass("ForceField")
		if not Hum or FF or Hum.Health <= 0 or IsTeamMate(Services.Players:GetPlayerFromCharacter(Hum.Parent),Player) or Hum.Parent == Character then return end
	end)
	Sounds.Unsheath:Play()
end


function Unequipped()
	MouseHeld = false
	if Touch then Touch:Disconnect();Touch = nil end
	for AnimName,anim in pairs(Animations) do
		if anim then
			anim:Stop()
		end
	end
	if CurrentMotor then
		CurrentMotor:Destroy()
	end
	if Tool:IsDescendantOf(workspace) and not Tool:IsDescendantOf(Character) then		
		for index = 1,#EquippedEvents do
			if EquippedEvents[index] then 
				EquippedEvents[index]:Disconnect();EquippedEvents[index] = nil
			end 
		end
	end
end

local Seed = Random.new()

function Activated()
	if not Shoving then
		if not Tool.Enabled or MouseHeld then return end
		Shoving = false
		Attacking = true
		
		MouseHeld = true	
		Animations.Charge:Play()
	end
end

function Deactivated()
	if not Shoving then
		if not Tool.Enabled or not MouseHeld then return end
		MouseHeld = false
		
		Tool.Enabled = false
		
		Shoving = false
		Attacking = true
		
		Hitbox.OnHit:Connect(function(hit, humanoid)
			if humanoid.Parent ~= script.Parent.Parent then				
				humanoid:TakeDamage(Properties.Damage)

				local Attachment = Instance.new("Attachment")
				Attachment.Parent = hit

				if Attachment.Parent.Name == "HumanoidRootPart" then
					Attachment.Parent = hit.Parent:FindFirstChild("Torso")
				end

				local SFXList = script:WaitForChild("FleshHit"):GetChildren()
				local RandomSFX = SFXList[math.random(1, #SFXList)]
				local SFXClone = RandomSFX:Clone()
				SFXClone.Parent = hit
				SFXClone:Play()
				delay(SFXClone.TimeLength, function()
					SFXClone:Destroy()
				end)

				local Blood = game:GetService("ReplicatedStorage").Miscs.BloodVFX.Normal:GetChildren()
				for i = 1, #Blood do
					local BloodClone = Blood[i]:Clone()
					BloodClone.Parent = Attachment
					BloodClone.Enabled = true
					delay(.01, function()
						BloodClone.Enabled = false
					end)
				end	

			end
		end)

		Hitbox:HitStart() --- Turns on the hitbox

		local AttackAnims = {--[[Animations.Slash,]]Animations.Stab}
		Sounds.Lunge:Play()

		Animations.Charge:Stop()

		local Anim = AttackAnims[Seed:NextInteger(1,#AttackAnims)]
		Anim:Play(0,nil);--Anim.Stopped:Wait()

		task.wait(Anim.Length/3)

		Hitbox:HitStop() --- Turns off the hitbox

		task.wait(.5)

		if CurrentMotor then 
			CurrentMotor:Destroy();CurrentMotor = nil
		end

		Tool.Enabled = true
		
		Shoving = false
		Attacking = false
	end
end

function Shove()
	if not db then
		if not Attacking then
			local ShoveHitbox = RaycastHitbox.new(Tool:WaitForChild("Handle").ShoveHitbox)
			Shoving = true
			Attacking = false
			db = true

			Tool:WaitForChild("Handle").Shove:Play()

			ShoveHitbox.OnHit:Connect(function(hit, humanoid)
				if humanoid.Parent ~= script.Parent.Parent or not script.Parent:WaitForChild("Handle").ShoveHitbox then
					script.Shoved:Play()
				end	
			end)

			Humanoid:LoadAnimation(Tool:WaitForChild("Anims").ShoveAnim):Play()

			ShoveHitbox:HitStart() --- Turns on the hitbox

			task.wait(.25)

			ShoveHitbox:HitStop() --- Turns off the hitbox

			task.wait(.75)
			
			Shoving = false
			Attacking = false
			db = false
		end
	end
end


Tool:WaitForChild("Client").Shove.OnServerEvent:Connect(Shove)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
Tool.Activated:Connect(Activated)
Tool.Deactivated:Connect(Deactivated)

1 Like

The tool counts as a hitbox for others because of this line here

You’re not checking if hit is a Handle of a tool. Not saying you should replace this line, (because you’re checking if the humanoid’s character isn’t the same as the one who performed the slash) but rather make another condition to check if hit.Parent isn’t a Tool class. Hopefully this helps.

1 Like

A tool contains a part so yea it does count as a hitbox

1 Like

You can do check if hitPart.Parent is a tool and when it is, just return end if you don’t wanna make the tool as a hitbox

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.