-
What do you want to achieve? Keep it simple and clear!
The viewport frame should always be on the monsters head. but its frozen mid air -
What is the issue? Include screenshots / videos if possible!
The camera stays in the air for some reason -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Devfourms
Code:
local gui = script.Parent
local viewportCamera = Instance.new("Camera")
viewportCamera.CFrame = workspace:WaitForChild("Monster", 30):FindFirstChild("Head").CFrame
viewportCamera.FieldOfView = 80
gui.ViewportFrame.CurrentCamera = viewportCamera
local detectZone: BasePart = workspace.DetectPart
while task.wait(0.5) do
gui.ViewportFrame:ClearAllChildren()
gui.ViewportFrame.CurrentCamera = viewportCamera
local parts = workspace:GetPartBoundsInBox(detectZone.CFrame, detectZone.Size)
for _, part in parts do
local clone = part:Clone()
clone.Parent = gui.ViewportFrame
end
end
Video: