Help with Region3

I’m currently trying to make so anyone who enters this region will be killed, I tried this script but it didn’t work. I tried printing but when I go in it doesn’t print past the if humanoid part. Can someone help me?

local regionPart = script.Parent.TouchPart
local pos1 = regionPart.Position - (regionPart.Size / 2)
local pos2 = regionPart.Position + (regionPart.Size / 2)

local region = Region3.new(pos1, pos2)

local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)

while wait(0.1) do
	for i,v in pairs(partsInRegion) do
		if v.Parent:FindFirstChild("Humanoid") then
			v.Parent.Humaoid.Health = 0
		end
	end
end
1 Like

The issue is that the region is only being checked once since it’s outside the while loop hence it’ll be empty. So yeah try it out, If it doesn’t work try visualizing it and see if you have the same problems as in this other post.


while wait(0.1) do
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i,v in pairs(partsInRegion) do
		if v.Parent:FindFirstChild("Humanoid") then
			v.Parent.Humanoid.Health = 0
		end
	end
end


2 Likes

Humanoids are not parts
and the guy aboves code will deal damage per body part

while wait(0.1) do
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i,v in pairs(partsInRegion) do
		if v.Name=='HumanoidRootPart' then
			v.Parent.Humanoid.Health = 0
		end
	end
end
1 Like