I'm trying to make a good punch tool but even though it is unequipped and I am not clicking it still does damage to the enemy NPCs. How can I fix this? (script) I've already tried things like: -tool.Activated -debounce
Here's the script:
local tool = script.Parent local hitsound = tool:WaitForChild("Hit") local canattack = tool:WaitForChild("CanAttack") local plr = tool.Parent.Parent local char = plr.Character or plr.CharacterAdded:wait() local larm = char:WaitForChild("LeftHand") local rarm = char:WaitForChild("RightHand") larm.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if canattack.Value == false then if hum then canattack.Value = true hitsound:Play() hum:TakeDamage(10) wait(.5) canattack.Value = false end end end) rarm.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if canattack.Value == false then if hum then canattack.Value = true hitsound:Play() hum:TakeDamage(10) wait(.5) canattack.Value = false end end end)
You should try raycasting renderstep on both arms, and if it finds a humanoid, the humanoid takes 10 damage. https://developer.roblox.com/en-us/articles/Making-a-ray-casting-laser-gun-in-Roblox https://devforum.roblox.com/t/raycasting-how-do-i-do-it/186446