Sometimes hits dos not register

im new to events and i was able to understand the basics. im making a combat game. in the video shown here, the arms is touching the dummy but for some reason it isnt registering in certain posistions and places. is it a bug? ill just send the code that actually matters.

local punchevent = script.Parent.Punch
local debounce = true

punchevent.OnServerEvent:Connect(function(players, nameofpl, valuetype)
	local eventfiredfinish = false
	if valuetype == "punchl" then
		print("Some bozo punched but ok")
		local arm = nameofpl:FindFirstChild("Left Arm")
		if arm == nil then
			warn("Error, cannot find arm for some reason")
		else
			arm.Touched:Connect(function(hit)
				local human = hit.Parent:FindFirstChild("Humanoid")
				if not human then return end
				if human and debounce and not eventfiredfinish then
					debounce = false
					human:TakeDamage(8)
					print("hit")
					task.wait(0.08)
					debounce = true
				end
			end)
		end
		task.wait(0.1)
		eventfiredfinish = true

.Touched event fires when collision happens, in your case collision is already happen.
I recommend you to use Raycasts or Shapecasts for making hitbox, using Touched event is really terrible for hitbox. I cant recommend you guides for raycasts, so try to find one

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.