Situating Items for Shelf System

I’m working on a system to display items (Roblox tools). I need to situate them on the display as shown below, where they appear to be resting on the surface, adjusted for the item size. How could I achieve this?

Thanks! :slight_smile:

U can create a attachment in the duck maybe called DisplayHolder. the attachment will be where the “counter” of the shop appear to be at.

When positioning the duck, you can set the duck position to the counter position + (duck Position - DisplayHolder.WorldPosition). Hope this helps a d happy new year :confetti_ball::confetti_ball:

hacky way using :GetBoundingBox()

local tool = script.Parent
local handle = tool:FindFirstChild("Handle")

local model = Instance.new("Model")

for _, instance in tool:GetChildren() do
pcall(function()
local newInstance = instance:Clone()
newInstance.Parent = model
end)
end

local targetCFrame = CFrame.new(10,10,10)
local yOffset = model:GetBoundingBox().Y/ 2
local offsetCFrame = CFrame.new(0,yOffset,0)

model:Destroy()

handle.Position = targetCFrame * offsetCFrame

(be aware of errors since mobile)

For better understanding, does GetBoundingBox() get the base of the item which could then be used for positioning it on the display?

Happy new year too!

While this probably would work, I’d have to create attachments for dozens of additional tools.

GetBoundingBox returns two values

  1. CFrame of the bounding box
  2. Size of the bounding box

And the bounding box is the smallest box that encapsulates every part in the model

Assuming the model has no primary part and its pivot is unchanged, you can add half of the height of the bounding box to the position, which makes the bottom of the lowest part touch the top surface. This only works well for models with a flat surface though, so you can use attachments if you want to do it manually

yes I forgot /2, my bad!
and it should be extentsize wich only returns the size:

local tool = script.Parent
local handle = tool:FindFirstChild("Handle")

local model = Instance.new("Model")

for _, instance in tool:GetChildren() do
pcall(function()
local newInstance = instance:Clone()
newInstance.Parent = model
end)
end

local targetCFrame = CFrame.new(10,10,10)
local yOffset = model:GetExtentSize().Y/ 2
local offsetCFrame = CFrame.new(0,yOffset,0)

model:Destroy()

handle.Position = targetCFrame * offsetCFrame