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?