How to make the tools fit perfectly in ViewPortFrame

Well I am trying make tools looks better in The Frame but Idk how should I choose CFrame values or anything else
That is how it looks right now

local ItemClone = ItemTemplate:Clone()
		local holder = ItemClone.Holder
		ItemClone.Parent = Container
		
		local viewportFrame = holder.ViewportFrame
		local viewItem = ReplicatedStorage:FindFirstChild("ToolModels"):FindFirstChild(toolName):Clone() -- !!!!!
		viewItem:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,-0.23,0),Vector3.new(0,0,0)))
		viewItem.Parent = viewportFrame

		local viewportCamera = Instance.new("Camera")
		viewportFrame.CurrentCamera= viewportCamera
		viewportCamera.Parent = viewportFrame
		viewportCamera.FieldOfView = 2
		viewportCamera.CFrame = CFrame.new(Vector3.new(0,0,0, Vector3.new(0,0,0)))

		object.ViewItem = viewItem
		object.TemplateButton = ItemClone
		print("WELLLOBOYS")

I am not good at using ViewportFrames, but you can set the camera position manually to make it look like your desired image.

how so? I didn’t know we could move Camera posision manually? if you mean viewportCamera.CFrame’s values well it is kinda hard cause it moves the object too much even +0.01 makes object not visible

I would like to go a little bit off topic for this post, using viewportFrame to display weapon inside the frame is not the best way to show how cool your weapon looks (if you care about it though). According to the Engine API. Any shadows and lights will not be displayed inside the viewportFrame which will make your model looks more of like dark and bland.

Yeah! I saw it but I want weapons to be inside the ShopGui so I had to use it and well I don’t mind much about shadows too

What I would suggest instead is… If you have a little bit of knowledge on using Blender, you can model the weapon yourself, and use a camera and light in Blender to take a .png image and add it to the template using ImageLabel. (It is what I am doing)

OH wow that is really a good idea to make it! But welp I have 0 talent on design I mean really if someone would ever tried to teach me anything about design or how to use blender he/she would get hysterics lol

It is really simple, and of course, fun! Using Blender to model how your weapon looks is much fancier than using… you know… part and assemble them together. There are tons of YouTube videos guiding you step by step on how to model low poly stuff like weapons, assets or maps. For beginner, I recommend Imphenzia’s youtube channel. The starting point is rough, but I guarantee that it will worth your every single second.

1 Like

To get it looking good, put your tool in workspace and angle your camera however you want on it. Then, Ctrl + C your camera (Copy it) and paste it into the viewport.

Then change the currentcamera of the viewport to the camera that is in the viewport.

After that, all you have to do is put the tool back into the viewport.

Sometimes there may be framing issues, so to get it just right, what I like to do is change the currentcamera of the viewport to your camera, however keep the tool in the viewport, and when it looks good copy your camera into the viewport.

(BTW “your camera” is the camera object in workspace which is always there. You can even try changing the camera in workspace’s FOV and it will change your actual camera’s FOV.)

The description of your topic is kinda vague, and I don’t really understand what you are trying to do. According to the title of your topic, it seems that you are trying to fit a model perfectly inside of a viewport frame.

There is a video made by sleitnick (aka crazyman32) that shows the math on how this could be accomplished.

2 Likes

That is A perfect video. Thanks! This is what I was wondering.

1 Like

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