What would be a good and accurate damage zone?

So recently I’ve been planning on making a RPG/Grinding/Open World game with special and magic moves on weapons. Of course I made a hitbox that would do damage to the Plr/Npc Humanoid that are in the skill’s AoE. Thing is that the hitbox use a “Touched” funtion and this kind of action tends to lead to very inaccurate damage. For exemple in my code I tried to make the health of the humanoid go down by 40HP but end up in draining full health along with lag. (See code bellow)
Now, here’s how my hitbox work, A Sphere named Hitbox with the script bellow is cloned and gets anchored into the workspace on top of the sphere summoner. When it is time of the explosion I just make the anchored false from another script for the hitbox to fall on the Player/NPC and then destroy it. Is there a better way to make a damage AoE?

Hitbox = script.Parent
dmgDone = false
game.ReplicatedStorage.Dark.DarkExplosion.OnServerEvent:Connect(function(plr)
	Hitbox.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
		if not hit.Parent.Humanoid:FindFirstChild(plr.Name) then
                if dmgDone == false then
                               dmgDone = true
				hit.Parent.Humanoid:TakeDamage(40)
				wait(0.2)
				Hitbox:Destroy()
                      end
		end
	end
end)
end)

Thank you!

1 Like