Shown model in GUI is compressed?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want the items shown to be normally in the GUI like this:

  2. What is the issue? Include screenshots / videos if possible! It looks like this in the GUI:

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried removing any welds so the parts would not be welded to the Handle when it gets resized but it does not seem to work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local m = Instance.new("Model")
m.Name = ""
m.Parent = player.Character
objs = {}
local scale
	
	if model:IsA("BasePart") then
		scale=1/5
		local function recurse(obj)
			for _,v in pairs(obj:GetChildren()) do
				local part
				if v:IsA("BasePart") then
					part = v:clone()
				elseif v:IsA("Hat") and v:findFirstChild("Handle") then
					part = v.Handle:clone()
				end
				if part then
					if part:FindFirstChildOfClass("Weld") then
						local weld = part:FindFirstChildOfClass("Weld")
						weld:Destroy()
					elseif part:FindFirstChildOfClass("WeldConstraint") then
						local weld = part:FindFirstChildOfClass("WeldConstraint")
						weld:Destroy()
					end
					local cf = part.CFrame
					part.Anchored = true
					part.Parent = m
					local orig=part.Size
					part.Size=part.Size*scale
					local mesh=part:FindFirstChild("Mesh")
					if mesh then
						mesh.Scale=mesh.Scale*scale
					end
					if mesh==nil then
						local mesh=Instance.new("BlockMesh",part)
						mesh.Scale=orig*scale/part.Size
					end
					local fire=part:FindFirstChildOfClass("Fire")
					if fire then
						fire.Size=fire.Size*scale
					end

					part.CFrame=CFrame.new(Vector3.new(0,0,0)+cf.p*scale)*(cf-cf.p)
					if part:findFirstChild("Decal") and part.Transparency ~= 0 then
						part:Destroy()
					elseif part.Name == "Head" then
						part.Name = "H"
					end
					if part.Parent == m then
						table.insert(objs,part)
					end
				elseif not v:IsA("Model") and not v:IsA("Sound") and not v:IsA("Script") then
					v:clone().Parent = m
				else
					recurse(v)
				end
			end
		end
		recurse(model.Parent)
	end
	
	local primary = Instance.new("Part")
	primary.Anchored = true
	primary.Transparency = 1
	primary.CanCollide = false
	primary.Name = "MODEL_CENTER"
	primary.FormFactor = "Custom"
	primary.Size = m:GetExtentsSize()
	primary.CFrame = CFrame.new(m:GetModelCFrame().p)
	primary.Parent = m
	m.PrimaryPart = primary
	for _,v in pairs(objs) do
		v.Anchored = false
		v.CanCollide = false
		v.Archivable = true
		local w = Instance.new("Weld",primary)
		w.Part0 = primary
		w.Part1 = v
		local CJ = CFrame.new(primary.Position)
		w.C0 = primary.CFrame:inverse()*CJ
		w.C1 = v.CFrame:inverse()*CJ
		v.Parent = m
	end
	CF = CFrame.new(0, 0, 0, -1, 0, -8.74227766e-008, 0, 1, 0, 8.74227766e-008, 0, -1)
	Active = false
	DistOffset = 0
	function index:SetActive(b)
		Active = b
	end
	function index:SetCFrame(cf)
		CF = cf
	end
	local function updateModel()
		primary.Anchored = false
		if Active then
			local posZ = GetDepthForWidth(primary.Size.magnitude, guiObj.AbsoluteSize.Y)
			local sizeX,sizeY = guiObj.AbsoluteSize.X,guiObj.AbsoluteSize.Y
			local posX,posY = guiObj.AbsolutePosition.X+(sizeX/2),guiObj.AbsolutePosition.Y+(sizeY/2)
			local pos = ScreenSpaceToWorld(posX,posY,posZ)
			local location = camera.CoordinateFrame * CFrame.new(pos.X, pos.Y, posZ)
			primary.CFrame = location * CF
		else
			primary.CFrame = CFrame.new()
		end
		primary.Anchored = true
	end
	local con = rs.RenderStepped:connect(updateModel)
	function index:End()
		con:disconnect()
		pcall(function ()
			m:Destroy()
		end)
		return
	end
	index.Object3D = m
	return index

^^^This is the module I used to show the model

function DisplayItem(item)
	if model3D then
		model3D:End()
	end
	local weapon = game.ReplicatedStorage.Items:FindFirstChild(item)
	model3D=Module3D:Attach3D(weapon.Handle)
	model3D:SetActive(true)
	runservice.RenderStepped:connect(function()
		model3D:SetCFrame(CFrame.Angles(0,tick()%math.pi*2,0))
	end)
end

^^^How I use the module to show the item

Items are basically consisted of a Model then a Handle, then parts of the models that are welded to the Handle. Please help!

1 Like

My first idea to you would be something like the following:

The model you’re using, should be welded with the correct offsets before usage. That is, using a plugin of some sort (or calculating the offsets yourself) to weld the different parts of the armor model together (best if they are just welded to one part, as further discussed below) (and other needed protocol, like making sure the parts are unanchored and massless). Have a primary/core part of the model that will remain anchored where all of the other armor parts are welded to THAT core.

Store this model somewhere, then when it needs using, clone it to the viewport frame and whatever you do, then set the cframe of the anchored core part to where it should be within that viewport.

Yes, all the models are correctly welded as they can be held as weapons etc. but I think it could be a problem with this code, should I remove it? I made the code anchor the parts shown in the GUI object so I most likely do not need this right?

    local primary = Instance.new("Part")
 	primary.Anchored = true
	primary.Transparency = 1
	primary.CanCollide = false
	primary.Name = "MODEL_CENTER"
	primary.FormFactor = "Custom"
	primary.Size = m:GetExtentsSize()
	primary.CFrame = CFrame.new(m:GetModelCFrame().p)
	primary.Parent = m
	m.PrimaryPart = primary
	for _,v in pairs(objs) do
		v.Anchored = false
		v.CanCollide = false
		v.Archivable = true
		local w = Instance.new("Weld",primary)
		w.Part0 = primary
		w.Part1 = v
		local CJ = CFrame.new(primary.Position)
		w.C0 = primary.CFrame:inverse()*CJ
		w.C1 = v.CFrame:inverse()*CJ
		v.Parent = m
	end

If the armour models already have all needed welds/motor6ds/weldconstraints to set the offsets of the different body parts to look like how it does in that screenshot you posted, then surely the code you’ve presented here adding welds to each instance in the model is completely unneeded and messes it up?

On initial glance, the code above the for loop looked correct but what I’ve noticed is you arent taking into account what I said. My idea is to not do any of the welding by live code and have it done through a plugin or something in studio before you move the model into the viewport frame, so that the code for presenting the model in the UI is very small and simplistic.

However, if you insist that this is done through code, I think the weld offsets are likely incorrect:

local w = Instance.new('Weld', v)

w.C0 = v.CFrame:Inverse()
w.C1 = primary.CFrame:Inverse()

w.Part0 = v
w.Part1 = primary

If that doesn’t work, try just swapping the order of setting the part0 n’ part1 with setting the C0 and C1