So i wanted to make a metal rod that you can attack with but for some reason it doesnt react when it hits anything
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Idle = Tool:WaitForChild("Idle")
local Attack = Tool:WaitForChild("Attack")
local Debounce = false
Tool.Equipped:Connect(function()
local Motor6d = Instance.new("Motor6D")
Motor6d.Part1 = Handle
Motor6d.Part0 = Tool.Parent["Right Arm"]
Motor6d.Parent = Handle
Motor6d.Name = "Motor6d"
local Humanoid = Tool.Parent:FindFirstChild("Humanoid")
local IdleLoaded = Humanoid:LoadAnimation(Idle)
local AttackLoaded = Humanoid:LoadAnimation(Attack)
IdleLoaded:Play()
end)
Tool.Activated:Connect(function(hit)
local Humanoid = Tool.Parent:FindFirstChild("Humanoid")
local IdleLoaded = Humanoid:LoadAnimation(Idle)
local AttackLoaded = Humanoid:LoadAnimation(Attack)
if Debounce ~= true then
print("Debounce is false")
IdleLoaded:Stop()
AttackLoaded:Play()
Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Humanoid.Parent.Name then
print("IsAHumanoid")
local EnemyHumanoid = hit.Parent.Humanoid
if hit.Parent:FindFirstChild("Hittable") and Debounce == false then
EnemyHumanoid:TakeDamage(15)
Debounce = true
task.wait(1)
Debounce = false
else
print("Cannot be hit")
end
end
end)
IdleLoaded:Play()
else
print("Debounce is true")
end
end)
Tool.Unequipped:Connect(function()
local Humanoid = Tool.Parent:FindFirstChild("Humanoid")
Handle.Motor6d:Destroy()
local IdleLoaded = Humanoid:LoadAnimation(Idle)
local AttackLoaded = Humanoid:LoadAnimation(Attack)
IdleLoaded:Stop()
end)
How can i make it react to hits?
Thanks in advance.