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 = Instance.new("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 = CFrame.new(Vector3.new(0,3,0), v.Handle.Position)-- Position of the camera
rare.Parent = player.PlayerGui.Inventory.Inventory[class.."Inv"]
print("You made it this far")
end
end
end
end
end
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.
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.
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:
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: