Unable to cast value to objects when using Rotated Region3 Module

I’m trying to use the Rotated Region3 Module created by EgoMoose, and when using it, I encounter an error saying ‘Unable to cast value to objects’, this is the code I’m using.

local RotatedRegion3 = require(script.Parent.RotatedRegion3)
-- required on top of the script, not required every time i want to create a hitbox.

local Hitbox = RotatedRegion3.new(Roller.Hitbox.CFrame, Roller.Hitbox.Size)
local Table = Hitbox:FindPartsInRegion3WithIgnoreList(Character, 200) -- error happens here

Does anybody know what I’m doing wrong, and if so, do you know how to fix it? Thanks, all help is appreciated.

1 Like

I can’t be completely sure of what’s going on because I don’t know what’s happening in the RotatedRegion3 function. If you posted the module code, that would help a lot.

In my experience with regions, the error “Unable to cast value to objects” means that a table was expected, but another value was recieved (i.e. an object).

The line with the error has Hitbox:FindPartsInRegion3*WithIgnoreList*. What is the IgnoreList? If you don’t have an IgnoreList, I’d remove the WithIgnoreList, unless if there’s something else going on that I don’t know about. In this line of code, I put nil where the list would go. Hopefully that helps :slight_smile:

local Table = Hitbox:FindPartsInRegion3WithIgnoreList(Character, nil, 200)

1 Like

It’s exactly like the non-rotated built-in Region3, FindPartsInRegion3WithIgnoreList expects a *table of things to ignore, you’re just passing a thing. That’s what the error means. It expects a list of objects, but you pass something that cannot be cast to a list of objects, so it errors. Try this instead:

local Table = Hitbox:FindPartsInRegion3WithIgnoreList({Character}, 200)

1 Like

Sorry for not updating on this topic, I have fixed the issue with the solution you gave, thank you.

1 Like