How do i get the bounding box of a tool?

So the roblox tool instance dont give the full boundary size and I wanna know how to get it.

Also for some reason the the weld on the tool breaks when I spin the tool in viewport frame
image

I dont think its a problem with my script. as there is no :Destroy() in it. except ofc updating it but it has nothing to do with it.

Try using a ‘WeldConstraint’ instance. To get a tool’s boundaries parent it to a model and call the GetExtentsSize method through/on that model.

already using a weld constraint. it breaks fsr and no its not disabled.

You need a world model in order for certain physics operations (joint instances rely on the internal physics engine) to be performed inside of a viewport frame.
https://developer.roblox.com/en-us/api-reference/class/WorldModel

ok mr genie. Thanks I will use it tomorrow as rn i cant.

1 Like

image
image

local Player = game.Players.LocalPlayer
local Backpack = Player.Backpack
local PromptPurchase = game.ReplicatedStorage.PromptPurchase
local ItemDecoy = script.Item
local Holder = script.Parent.Holder
local BackpackItems = Backpack:GetChildren()
table.sort(BackpackItems,function(a,b)
	return a.Config.Price.Value < b.Config.Price.Value
end)

local Guns = Player.Guns
local MeleeWeapons = Player.MeleeWeapons
local Primary = Player.Primary
local Secondary = Player.Secondary
local Melee = Player.Melee

repeat wait() until game:IsLoaded()

local function rotate(o)
	local i = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,-1,false,0)
	local g = {Orientation = Vector3.new(360,360,360)+o.Orientation}
	game:GetService("TweenService"):Create(o,i,g):Play()
end

local function Update()
	for i,v in pairs(Holder:GetChildren()) do
		if v:IsA("Frame") then
			v:Destroy()
		end
	end
	
	for i,v in pairs(BackpackItems) do
		local Item = ItemDecoy:Clone()
		Item.Parent = Holder
		Item.IName.Text = v.Name
		Item.Buy.Text = "Purchase ("..v.Config.Price.Value..")"

		local C = Instance.new("WorldModel")
		for i,v in pairs(v:Clone():GetChildren()) do
			v.Parent = C
			if v:IsA("BasePart") then
				v.Anchored = true
			end
		end
		for i,v in pairs(C:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") or v:IsA("ModuleScript") then
				v.Disabled = true
			end
		end
		C.PrimaryPart = C.Handle
		C.Parent = Item.Image
		
		rotate(C.Handle)
		
		local Cam = Instance.new("Camera")
		Cam.Parent = Item.Image
		Item.Image.CurrentCamera = Cam
		local dist = C:GetExtentsSize().Magnitude
		Cam.CFrame = CFrame.new(C.Handle.Position+Vector3.new(0,0,dist),C.Handle.Position)

		if string.find(Guns.Value,v.Name) or string.find(MeleeWeapons.Value,v.Name) then
			Item.Buy.Text = "Equip"
		end
		if string.find(Primary.Value,v.Name) then
			Item.Buy.Text = "Equipped (Primary)"
		end
		if string.find(Secondary.Value,v.Name) then
			Item.Buy.Text = "Equipped (Secondary)"
		end
		if string.find(Melee.Value,v.Name) then
			Item.Buy.Text = "Equipped (Melee)"
		end
	end
end

Update()

Primary.Changed:Connect(Update)
Secondary.Changed:Connect(Update)
Melee.Changed:Connect(Update)
Guns.Changed:Connect(Update)
Melee.Changed:Connect(Update)

I dont understand anything now. works like the same the bounding problem is fixed just the weld one is left

Joint instances break when you modify a part’s ‘Position’/‘Orientation’ properties like that. You can either rotate the tool’s bounding model itself via PivotTo or remove the WorldModel and instead rotate the camera 360 degrees around the tool’s bounding model.

OH I FORGOT ABOUT THE CAMERA. man how th are you so smart? Did you like red LuaU for like 10 years or something? I wanna know so I can be as genius as you are :smiley:

1 Like

doing that makes the camera go weird it wont go around the tool