Region3 is giving me pain and suffering

alright so basically I have this torch that uses two Region3s in order to detect certain hitboxes touching it, one for melting ice within a radius and one for being put out by coldness within a radius

The script uses EgoMoose’s RotatedRegion3 ModuleScript in order to get more accurate region3s, it worked before with another asset I made less than a week ago.

The full script for one of the Region3s is the following;

local RunService = game:GetService("RunService")
local Region3Thing = require(script.RotatedRegion3)

RunService.Stepped:Connect(function()
	if script.Parent.Parent.HitboxEnabled.Value == true then
		print("hitbox active thingy 2")
		local TableThing = {}
		for i,w in pairs(workspace:GetDescendants()) do
			if w.Name == "BlueIce" or w.Name == "Ice" then
				TableThing[i] = w
			end
		end
		print(TableThing)
		local R3 = Region3Thing.FromPart(script.Parent)
		local AnythingInRegion = R3:FindPartsInRegion3WithWhiteList(TableThing, 500)
		print(AnythingInRegion)
		if AnythingInRegion then
			for i,w in pairs(AnythingInRegion) do
				if w.Name == "Ice" or w.Name == "BlueIce" then
                    print("touching some ice")
				end
			end
		else
			R3:Destroy()
		end
	end
end)

It’s supposed to check for certain hitboxes in the workspace and put them into a table, then run that table through a FindPartsInRegion3WithWhiteList function every frame in order to find any potential hitboxes.

as for prints, these two print what they are meant to

print("hitbox active thingy 2")
print(TableThing)

( TableThing is meant to just print the objects in the workspace that are listed so the FindPartsInRegion3 can use them in a whitelist )

however when it’s ran through AnythingInRegion as a variable and then printed here

		local AnythingInRegion = R3:FindPartsInRegion3WithWhiteList(TableThing, 500)
		print(AnythingInRegion)
		if AnythingInRegion then
			for i,w in pairs(AnythingInRegion) do
				if w.Name == "Ice" or w.Name == "BlueIce" then
                    print("touching some ice")
				end
			end
		else
			R3:Destroy()
		end

the table simply returns

{}

just {}, nothing else.

Evidentally there is a problem with the code but I’ve spent so much time running through possible solutions that I’m starting to lose motivation on it.

I’ve tried making it one Region3, I’ve tried experimenting with different types of FindPartsInRegion3, and nothing.

Any help would be greatly appreciated as even my friend who knows WAY more about scripting than me couldn’t figure it out.

Did this return anything?

30 Letters

I will assume that TableThing likely contains items. Your issue could be that the FindPartsInRegion3WithWhiteList expects a table, the way you have so far would mean it would be given a dictionary, instead of TableThing[i] = w, try doing table.insert(TableThing, w)

1 Like

yes, it returns any part in the workspace named “BlueIce” or “Ice” in a single table, the part that doesn’t print what I want is AnythingInRegion

of course the solution was something completely arbitrary that I hadn’t thought of lol

thanks for the help man I appreciate it

1 Like