Model not showing correctly on the Viewport

Hello everyone,

I’m using a script to turn a Tool into a model and then parent it to the viewport, it works if the player hasn’t equipped the tool or moved while equipping it. However, when either of those happen then the tool deform and doesn’t stay in place like this:
(The last 2 tools from the right only show the handle correctly but the other parts aren’t in their right position)

here is the code responsible for changing the tool to a model:


					local ViewPort = ViewPortFrame:Clone()
					local ViewPortCam = Instance.new("Camera")
					local Clone = item:Clone()
					local ItemGroup = Instance.new("Model")
					
					--- Needed variables to construct the Viewport ^^^

					for i,v in ipairs(Clone:GetChildren()) do -- This will clone the tool and turn it to a model
						if v:IsA("BasePart") then
							v.Parent = ItemGroup
						end
					end 

					Clone:Destroy()
					ItemGroup.PrimaryPart = ItemGroup:FindFirstChild("Handle")
				
					ItemGroup.Parent = ViewPort
					ItemGroup:PivotTo(CFrame.new(0,0,0) * CFrame.Angles(0,0,0))
					ItemGroup:PivotTo(CFrame.new(0,0,0) * CameraSettings.Camera.ModelOrientation)
					ViewPort.CurrentCamera = ViewPortCam
					ViewPortCam.Parent = ViewPort
					ViewPortCam.CameraType = Enum.CameraType.Scriptable
					ViewPortCam.CFrame = CFrame.new(ItemGroup:GetPivot().Position + CameraSettings.Camera.Position  * CFrame.Angles(0,0,math.rad(35))
					ViewPortCam.FieldOfView = CameraSettings.Camera.FOV 
					-- These are used to adjust the Viewport based on the tool shown ^^^
					ViewPort.Parent = slot

Thank you.

I suggest duplicating the tool so that you have a viewport model and the actual tool, you can also check if the player has a tool by checking the child-added function to the player to see if they have the tool.

Well I’m not having a problem with detecting the tool itself but rather the position of the tool’s parts are not consistent.

Fixed the issue, it turns out that you need to parent all the parts to the handle to accurately move them

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.