-
What do you want to achieve? A working viewport frame for my Hotbar system.
-
What is the issue? The hotbar isn’t doing anything/doesn’t work.
-
What solutions have you tried so far? Plenty, I’ve tried readjusting the Camera multiple times and the object too. None of it worked, I also looked at YT tutorials, none of them worked either
game.ReplicatedStorage.ViewPort.OnClientEvent:Connect(function(item:Tool,slot:Frame)
--[[
Variable "item" is a Tool/Equippable
Variable "slot" is a GUI Object, whichs children include:
{
Viewport:ViewportFrame,
Button:TextButon,
Label:TextLabel,
ImageLabel:ImageLabel
}
]]
for i,v in pairs(slot:GetDescendants()) do
if v:IsA("Model") then
v:Destroy()
end
end
local preview = item:Clone()
local viewPort:ViewportFrame = slot:WaitForChild("Viewport")
viewPort.Active = true
local handle:Part = preview:WaitForChild("Handle")
preview.Parent = viewPort
handle.Anchored = true
local model = Instance.new("Model",viewPort)
handle.Parent = model
preview:Destroy()
model.Name = "PreviewModel"
local cameraCF = CFrame.new(Vector3.new(0,0,0),Vector3.new(0,0,90))
handle.CFrame = cameraCF*CFrame.new(cameraCF.LookVector*10)*CFrame.Angles(0,0,0)
local camera = Instance.new("Camera")
camera.Parent = viewPort
camera.FieldOfView = 9
camera.CFrame = cameraCF
viewPort.CurrentCamera = camera
--print("Viewport Created,\nInfo:\nCamera: " .. tostring(camera) .. " Camera Parent: " .. tostring(camera.Parent) .. "\nModel: " .. tostring(model) .. " Model Parent: " .. tostring(model.Parent))
end)