Getting Tool (Weapon) to collide/knock back other players

Currently I have a tool I created with an animation that has the ability to knock back a player when it collides.

Within the tool I created a part called “SwipeHitBox” which is a hitbox that goes around the end of WarHammer like tool. It has “CanCollide” set to true and this tool is kept in StarterPack.

When I use the animation to test to swing the WarHammer at something it just goes through and doesn’t collide. I don’t believe anything is wrong with the code. However, I’ll copy-paste it here.

LocalScript for WarHammer Tool

local Tool = script.Parent
local animation = script.Parent:FindFirstChild("Animation")

local canSmash = true
local debounce = 5



Tool.Activated:Connect(function()
	local Character = Tool.Parent
	local Humanoid = Character.Humanoid
	local SmashAnimation = Humanoid:LoadAnimation(animation)
	if canSmash then
		canSmash = false
		SmashAnimation:Play()
		wait(debounce)
		canSmash = true
	end
end)

Script under SwipeHitBox

while true do
	wait(0.1)
	script.Parent.Velocity = script.Parent.CFrame.LookVector*85
end

StarterPlayer script, I’ve tried both local and not local

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

debounce = false

char.Humanoid.Touched:Connect(function(hit)
	if hit.Name == "SwipeHitBox" and debounce == false then
		debounce = true
		local clone = game.ReplicatedStorage.Effects.Part
		local part = clone:Clone()
		part.Parent = char.HumanoidRootPart
		part.Position = char.HumanoidRootPart.Position
		part.Position = part.Position - Vector3.new(2,0,0)
		game:GetService('TweenService'):Create(part,TweenInfo.new(0.3,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Size = Vector3.new(0.2,15,15),}):Play()
		
		game:GetService("Debris"):AddItem(part,1)
		wait(0.2)
		debounce = false
	end
	
end)

Why is part/tool not colliding with the player or knocking player back?

Not sure why your Tool is not colliding. Does it have CanCollide and CanTouch both turned on in the “SwipeHitBox”. I would recommend using a Server script in the Tool to detect the Touched event

local Tool = script.Parent
local swipeHitBox = Tool.SwipeHitBox

swipeHitBox.Touched:Connect(function(touchedPart)
			print(touchedPart)
		end)

See what that results in. It should tell you when the Tool actually hits something. In your example, you were applying a check to the Charcater in StarterPlayer script which is the wrong way to do it.

I do have CanCollide and CanTouch on. With the touch funtion it does show it’s making contact with objects. However it’s still passing through objects. I noticed when I removed the script under SwipeHitBox it becomes less glitchy. With the script it messes with the jump essentially.


while true do
	wait(0.1)
	script.Parent.Velocity = script.Parent.CFrame.LookVector*85
end