Region3 detect only once character

Hello, I was writing my combat script for my game by using region3 but i got a problem that it detect only once thing in region 3 can anyone help me?

Here my script

		local function Hitbox()
			local region,part do
				part = Instance.new("Part")
				part.Parent = character
				part.Size = Vector3.new(10,10,10)
				part.Transparency = 0.5
				part.Anchored = true
				part.CanCollide = false
				part.CFrame = character.HumanoidRootPart.CFrame
				local position, half_size = part.Position, part.Size *.5
				region = Region3.new((position - half_size), (position + half_size))
			end
				local getTouchingParts = game.Workspace:FindPartsInRegion3(region, part)
			for i,v in pairs(getTouchingParts) do 
					if canDamage == true then
						if v.Parent ~= character then
							if v.Parent:FindFirstChild("Humanoid") then
								local hum = v.Parent:FindFirstChild("Humanoid")
								print(v.Parent.Name)
								if combo == 5 then
									local bv1 = Instance.new("BodyVelocity", hum.Parent.HumanoidRootPart)
									bv1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
									bv1.Velocity = character.HumanoidRootPart.CFrame.LookVector * 100
									Debris:AddItem(bv1, .2)
								end
							hum:TakeDamage(10)
							wait()
							canDamage = false
							end
						end
					end
				end
			Debris:AddItem(part, .1)
		end

( i think it because the my region 3 create only once times, but i dont know how to create region3 multiple times )

I’m pretty sure your issue is coming from the fact that you are setting ‘canDamage’ to false after damaging one enemy so therefor your if statement above wont get triggered again.

1 Like

i tried print part in region3 name, and it print only once in region3 :sweat_smile:

ohh when i removed canDamage it deal aoe damage

Region3 is deprecated use overlapparams instead OverlapParams

2 Likes

Does OverlapParams scripting like region3?

Its similar but easier to use and it allows rotation

1 Like

As @PeterClawit you should be using Workspace:GetPartBoundsInBox with OverlapParams as it is much, much easier to use and allows for rotation. To implement rotation for Region3 is much more complicated if you want to use rotations with it. Learn about it GetPartsBoundInBox here:
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartBoundsInBox

Region3 is not deprecated. Some of its functions are.

1 Like

set max parts

local getTouchingParts = game.Workspace:FindPartsInRegion3(region, part, math.huge)

the default max parts is 20