Im trying to inflict damage on a dummy with a punching script I made. In this script I used a part that appears and disappears each time the mouse is clicked, it inflicts damage but not all the time. This is the only hitbox method I know so please help me.
This is what it looks like: Punches
The grey part is my hit box and the dummy should take damage each time it touches it.
And this is a part of the script I'm using:
local debounce = false
local Box = Instance.new("Part")
local boxweld = Instance.new('Weld')
boxweld.Name = "CWelds"
boxweld.Part0 = Player.Character.Torso
boxweld.Part1 = Box
boxweld.Parent = Player.Character.Torso
boxweld.C0 = CFrame.new(0, -1, -2)*CFrame.Angles(0, 0, 0)
Box.Size = Vector3.new(4, 5, 4)
Box.CanCollide = false
Box.Anchored = false
Box.Transparency = 0.5
Box.Name = "Box"
Box.Parent = Player.Character
Box.Touched:connect(function(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h and (not debounce) and (h.Parent ~= Player.Character) then
debounce = true
h:TakeDamage(math.random(10, 14))
Box:Destroy()
end
end)
This isnt all of the script however it is where the problem is, if you need the whole script please tell me.

2 comments
Thanks, I'll leave this open for a little bit longer to see if there are any other suggestions but if not I'll accept your answer.
The alternative is to simply check if the arm collides with the player using Touched. I wouldn't trust it for this case, and I'd rely on a raycast if I were you. Even more important to rely on a raycast if you're using networked combat, which you are.