I want my viewport frame to show when the player is holding a tool. It shows the hand come up on the character, so I know it’s equipping it, but the model itself is never visible. What can I do to fix this?
In case it’s needed, this is the code that parents the tool to the character:
function InvenClientActions.EquipItem(equip)
local PlayerInventory = TheValleyFunctions.GetInventory()
local Character = ViewportFrame.WorldModel:FindFirstChild(Player.Name)
--Reset tools
for i,v in pairs(Character:GetChildren()) do
if v:HasTag("ItemTool") then
v:Destroy()
end
end
RS.Inventory.EquipItem:FireServer(equip)
if equip then
local ItemName,_ = next(PlayerInventory.EquippedItem)
ItemTools[ItemName]:Clone().Parent = Character--------------------This part
end
end
Wish I could help you more than just recommending you to check if the tool exists in the Viewport frame. Other than that i really have no experience when it comes to viewport frames
When you see the tool on your screen(nobody elses), can you at least see the tool on yours? Or it’s not showing it whatsoever? Have you tried checking the transparency of the tool? I would select the tool in the workspace exactly where it is and see what it highlights. It always shows a blue highlighter around it, even if it is invisible.
I can see the actual player holding it, but I can’t see it in the viewport frame. I checked its transparency and there’s no issues there. I also tried it with all other items I had in the game and none of them work so it’s not an instance-specific problem
Alright I think my answer to this should fix the problem completely. Whatever you are doing with the tool, I would just say stop it entirely. We want to get this working first, you can do whatever you please with the code after we actually get it visible. I just want to help you fix the problem. The character is very clearly marked as
local Character = ViewportFrame.WorldModel:FindFirstChild(Player.Name)
While your tool on the other hand is marked as
local ItemName,_ = next(PlayerInventory.EquippedItem)
ItemTools[ItemName]:Clone().Parent = Character
You will need to do what you’re doing to the character, to the tool. Otherwise this issue will persist. You obviously got it working for the character. I’ll give a good example what it should look like.
I think I figured out the issue. I checked the position property of the tool and it was super far away from the viewport’s FOV. When I get it in there though, I noticed that it never moved when I equipped and unequipped it. Could it be an attachment issue?