Not really much else to say. I've tried the following method-
--returns a list of positions function PopulateList(model) local tbl = { x = {}, y = {}, z = {}, } for _,v in pairs(model:GetChildren()) do tbl.x[#tbl.x + 1] = v.Position.X + (v.Size.X / 2) tbl.y[#tbl.y + 1] = v.Position.y + (v.Size.y / 2) tbl.z[#tbl.z + 1] = v.Position.z + (v.Size.z / 2) end return tbl end --returns the corners of the object in question function SortGL(tbl) local gx, gy, gz, lx, ly, lz = 0, 0, 0, 1000, 1000, 1000 local index = 1 for _,v in pairs(tbl) do for _,pos in pairs(v) do if index == 1 then if pos > gx then gx = pos elseif pos < lx then lx = pos end elseif index == 2 then if pos > gy then gy = pos elseif pos < ly then ly = pos end elseif index == 3 then if pos > gz then gz = pos elseif pos < lz then lz = pos end end end index = index + 1 end gpos = Vector3.new(gx, gy, gz) lpos = Vector3.new(lx, ly, lz) return gpos, lpos end function GenerateHitbox(obj) local gpos, lpos = SortGL(PopulateList(obj)) local hitbox = Instance.new("Part", obj) hitbox.Name = "Hitbox" hitbox.Transparency = 0 hitbox.Position = gpos end
... and the result isn't anything like what I wanted (the position is very far off). How would I get the exact center of a model?
Simply use model:GetModelCFrame().p
to get the position matrix of the CFrame, but if you want the rotation matrix included, just use model:GetModelCFrame()