Probably an issue with the Camera. IDK if it has to be parented to anything, so you could try that. Also, the default CFrame value is an identity matrix, meaning your camera is inside the item you want to preview. Just offset it in a direction.
You can just replace the *10 with a smaller number. You can go even further and assign a different multiplier for each item so that larger items scale accordingly.
Try doing ClonedItem.CFrame = (Camera.CFrame + Camera.CFrame.LookVector * 4) * CFrame.Angles(math.pi/2, 0, 0)
this will rotate the item 90 degrees on the X axis
You have to save it as a table for each item. I’d suggest storing it as a separate module with the item names as indices. You can also store some extra stuff in it like the name to display. You’ll have to mess around with the Orientation property in here until you get the desired result. Note that the orientation is done in radians, not degrees.
--ModuleScript "ItemData" parented to the script the code you posted is located in
return {
Katana = {
DisplayName="Katana",
ViewportDistance = 7,
ViewportOrientation = {0,0,0}
},
Shuriken = {
DisplayName="Shuriken",
ViewportDistance = 6,
ViewportOrientation = {math.rad(90),0,0}
}
}
Now to implement this into your current script:
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Weapons = ReplicatedStorage:WaitForChild('Weapons')
local ItemData = require(script:WaitForChild("ItemData"))
return function(viewport, item, itemType)
local Data = ItemData[itemType]
local StoredItem = Weapons[itemType .. 's'][item].Handle
local ClonedItem = StoredItem:Clone()
local Camera = Instance.new('Camera')
Camera.FieldOfView = 60
ClonedItem.Parent = viewport
--The "or" part is to avoid errors if data of an item is icomplete
ClonedItem.CFrame = CFrame.Angles(unpack(Data.ViewportOrientation or {0,0,0})) + Camera.CFrame.LookVector*(Data.ViewportDistance or 10)
viewport.CurrentCamera = Camera
end