I am making a hotbar system and I want to like have the tool instead of the image. So its done but idk how can I get the size of a tool so that it fits in the viewportframe neatly.
Hope it helps.
local vpf = Instance.new("ViewportFrame") -- ViewportFame
local weapon = Self:WaitForChild("Hammer") -- Tool Weapon
local hotbar = Self:WaitForChild("Hotbar") -- The hotbar
local hotbar_capacity = 8 -- Number of spaces on the hotbar
local current_hotbar = 5 -- The hotbar number we are going to put the weapon on
-- Getting the weapon Handle into the ViewportFrame
local clone = weapon.Handle:Clone()
clone.Parent = vpf
clone.Anchored = true
-- Making the Camera for the ViewportFrame
local cam = Instance.new("Camera")
cam.Parent = vpf
cam.CFrame = CFrame.new(clone.Position + Vector3.new(0, 0, 3), clone.Position)
-- Setting the VPF Position and Camera
vpf.CurrentCamera = cam
vpf.Size = UDim2.new(0, hotbar.AbsoluteSize.X / hotbar_capacity, 1, 0)
vpf.Position = UDim2.new(0, vpf.AbsoluteSize.X * (current_hotbar - 1), 0, 0)
vpf.Parent = hotbar
oh no I forgot I made this topic. I am sorry I actually did solve this by making the tool into a model… but ill mark urs as solution.