So, the only way I think I can make hitboxes is to use an actual hitbox(a part with collision to false, and GetTouchingParts). But I really want to use magnitude. The game I am making is a building and breaking style game, where you have tools that break things. And it would be a pain to define every different object that is breakable to use .Magnitude. Is there a better way of doing this? Or, is there a way to use .Magnitude without defining every single object(as a variable).
All help is appreciated, and I will clarify if you don’t understand.
You could use a Region3 around the player as a “hitbox” and use Workspace:FindPartsInRegion3() to get any parts that are inside the region. The parts inside the region would be considered inside the hitbox of the player.
local Position = Vector3.new(0,0,0)
local Size = Vector3.new(0,0,0)
local Hitbox = Region3.new(Position-(Size/2),Position+(Size/2))
local PartsInRegion = game.Workspace:FindPartsInRegion(Hitbox) -- array
You would need to update the position of the region every frame so consider binding it to RunService.RenderStepped.
Yes that will work, you can create the region when the tool is activated and then check whatever parts are inside. Make sure you ignore the parts that are from your own character though.
local Region = Region3.new()
Region.CFrame = CFrame.new(0,0,0)
Region.Size = Vector3.new(0,0,0)
You’re trying to edit a readonly data.
local Position = Vector3.new(0,0,0)
local Size = Vector3.new(0,0,0)
local Region = Region3.new(Position-(Size/2),Position+(Size/2))
local PartsInRegion = workspace:FindPartsInRegion3(Region) -- Returns array with objects in region