Viewport camera position help!

add.AddedEvent = function(item, class, player) -- Starting the game and gaining something like a sword  (class - Weapon/Potion/Armour)
	local ReplicatedFirst = game:GetService("ReplicatedFirst")
	local items = ReplicatedFirst[class]:GetChildren()
	for i, v in pairs(items) do
		if v.Name == item.Name then	
			for num, rarity in pairs(script.Rarities:GetChildren()) do
				if v.Rarity.Value == rarity.Name then	
					--print(item.Name, class, player.Name)
					local rare = rarity:Clone()	-- Clone the rarity ui
					local clone = v:Clone() -- Cloning the tool
					clone.Parent = rare.ItemView -- Setting the tool to the viewportFrame
					local Camera ="Camera") -- Creating a Camera
				    rare.ItemView.CurrentCamera = Camera -- Setting the viewports CurrentCamera to the new one
					Camera.Parent = rare.ItemView -- The camera parent is the viewportFrame
		   >>>>>>	Camera.CFrame =,3,0), v.Handle.Position)-- Position of the camera
					rare.Parent = player.PlayerGui.Inventory.Inventory[class.."Inv"]
					print("You made it this far")

So the line which sets the camera’s angle is the line which has >>>>>

So I want it so the item which is a tool displays in the middle of the viewportFrame. Any help.

I won’t be responding right now as I need to go off, but when I am back on I will look at all the replies. Yes I have read forum and other sources but they don’t work for some reason. Any help would be appreciated.


Handle Position:

See if this works. You can adjust the -4 for how far you want it to be. Closer to 0 means it will be zoomed in, further away means it’ll be zoomed out. This may have trouble for larger tools, if any of your tools have this issue let me know and I can make it adjust depending on size.

Camera.CFrame = +, 1, -4), v.Handle.Position)
1 Like

Doesn’t seem like you’re setting the camera’s CameraType to Scriptable.
This should work for that, not 100% sure if it’s the solution for your issue though:

Camera.CameraType = Enum.CameraType.Scriptable

I’ll be sure to check this when I’m on, I’m currently on my phone. So thanks for the reply.

I’ll try this out when I’m on although does it need to be scriptable even it’s going to be a fixed position.

1 Like

Yeah, pretty sure it has to be scriptable when you’re changing its position.

1 Like

image It shows up now, it just really zoomed out.

So I changed the value to 0,0,-1 and it zoomed in now, but is there anyway to rotate it?

If you want a different angle, you can adjust the X and Y axes. It should always point towards the item, unless it’s so far away you can’t see it.

If you want it constantly turning, you’ll have to write a loop that applies a rotation.

So, I been trying to get this closer but for some reason it won’t, I’m guessing it goes in the same direction as the rotate tool.


Camera.CFrame = +, 2, 1), item.Handle.Position)

It looks like the tools are larger than the handle itself. You can adjust where it looks by offsetting the second parameter, or changing what part it centers on instead of the handle. For example:

Camera.CFrame = +, 2, 1), item.Handle.Position +, 2, 0))

1 Like

Thanks, this works, I really appreciate it.

1 Like