I want the hitbox to only affect other players and not the one using it i've sort of succeeded in that so far but the issue is that .touched isnt consistent with detection is there a way i can fix this?

the part is moved to be consistent with the player's position, which i assume is the problem

hitbox.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(offsetX,offsetY,offsetZ)
	hitbox.Touched:connect(function(part)
		if part:IsA"BasePart" or part:IsA"MeshPart"  then
			local hitPlayer = getPlayer(part.Parent:FindFirstChild("Humanoid"))
			print(hitPlayer)
			if playerFrom.Character.Name ~= hitPlayer.Character.Name then
				hitPlayer.Character.HealthVal.Value = hitPlayer.Character.HealthVal.Value - damage
				hitbox:Destroy()
				return
			end
		end
	end)
	RunService.Heartbeat:Connect(function()
	hitbox.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(offsetX,offsetY,offsetZ)
end)

2 comments

1

I don't think there are any other alternatives

0

There is 1 alternative i could think of. But im not sure how you'd do it. You'd have to play around the the 'Magnitude' property so if it gets close enough it would fire. Not completely sure how you'd do it. But that's why i didnt put this as an answer.