#viewport frame not showing ANYTHING

1 messages · Page 1 of 1 (latest)

frank coral
#
local players = game:WaitForChild("Players")
local player = players.LocalPlayer
local time = 0
local target = player.PlayerGui:WaitForChild("shopping").Frame.ViewportFrame:WaitForChild("head")
local cam = player.PlayerGui.shopping.Frame.ViewportFrame.CurrentCamera

game.ReplicatedStorage.remoteevents.shop.OnClientEvent:Connect(function()
    local currentcam = Instance.new("Camera")
--    currentcam.CFrame = CFrame.new(Vector3.new(41.974, 5.008, -10.863), Vector3.new(-29.531, -97.991, 0))
    currentcam.Parent = player.PlayerGui.shopping.Frame.ViewportFrame
    currentcam.Name = "viewportcam"
    cam = player.PlayerGui.shopping.Frame.ViewportFrame.viewportcam
    print("camcreated")
    local part1 = Instance.new("Part")
    part1.Size = Vector3.new(4, 4, 4)
    part1.Position = target.Position -- Center of ViewportFrame
    part1.Parent = player.PlayerGui.shopping.Frame.ViewportFrame 
    part1.Material = Enum.Material.Plastic
    part1.BrickColor = BrickColor.new("Bright red")
    local light = Instance.new("PointLight")
    light.Parent = player.PlayerGui.shopping.Frame.ViewportFrame
    light.Range = 100
    light.Brightness = 2  -- Extra bright for testing
    while true do
        print("started")
        time+= 0.02
        cam.CFrame = CFrame.new(
            target.Position + Vector3.new(math.cos(time) * 10, 0, math.sin(time) * 10),
            target.Position
        )
--        local part = Instance.new("Part")
--        part.CFrame = cam.CFrame
--        part.Parent = game.Workspace
--        part.Anchored = true
--        part.CanCollide = false
--        part.Size = Vector3.new(1, 1, 1)
--        part.Transparency = 0
        print("SPINNING")
        
        task.wait()
    end
end)
--player.PlayerGui.clicking.Enabled == false
#

so when i use the script to make a new camera and move its CFrame that way, i made it leave a trail of blocks to make sure it was spinning. as you can see there they are. so it is working. no errors in the output log or anything. but the item i want to view in my viewport isnt showing up, but its there in the center of the circle (its coded to literally take its position and orbit it, so if it didnt exist or wasnt there, it wouldnt circle it.)

#

but if i use a camera i got from duplicating my current camera looking at the object, and setting it as the viewport frame current camera, its visible, but wont respond to being defined in the script, saying it isnt a child of whatever parent i put it in and targeted, and its true when you play test, cameras hide themselves from explorer but still exist (i know this because in the viewport frame the object is still visible when i start the playtest, but just isnt spinning obviously)

#

so my options are find a way to use premade cameras i set before playtesting and using that to orbit, or find a way to make objects visible in the viewport frame thats spawned in from the script

frank coral
#

i think the issue is that when the camera spawns in, i noticed in playtest that the current camera of viewport frame is empty, so its not able to see the objects in viewport frame, but now no matter what i do its not setting the current camera to the camera i made

minor willow
#

dawg wdym waitforchild players

#

it's getservice

frank coral
#

whats the difference since players is parented in game.