"Tried to index number with "Hitbox"

I am really confused by the error message, that appears just like the title

This is the code I am trying to make, I am making a script that generates trees on a procedurally generated world

Here is the line of the error:
local Region = Region3.new(Vector3.new(tree.Hitbox.Position - tree.Hitbox.Size),Vector3.new(tree.Hitbox.Position + tree.Hitbox.Size))

1 Like

You can’t index a number with Size and Position itself. You would have to use Position.X or Size.X since it is just a single number.

1 Like

The problem still persists

local Region = Region3.new(Vector3.new(tree.Hitbox.Position.X - tree.Hitbox.Size.X,tree.Hitbox.Position.Y - tree.Hitbox.Size.Y, tree.Hitbox.Position.Z - tree.Hitbox.Size.Z),Vector3.new(tree.Hitbox.Position.X - tree.Hitbox.Size.X,tree.Hitbox.Position.Y - tree.Hitbox.Size.Y,tree.Hitbox.Position.Z - tree.Hitbox.Size.Z))