Hello,
I have a script:
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Values = ReplicatedStorage:WaitForChild('Values')
local Speaker = Values:WaitForChild('Speaker')
local ViewportCamera = Instance.new('Camera',script)
ViewportCamera.CameraType = Enum.CameraType.Scriptable
local ViewportPoint = Vector3.new(0,0,0)
local ViewportFrame = script.Parent
ViewportFrame.CurrentCamera = ViewportCamera
Speaker:GetPropertyChangedSignal('Value'):Connect(function()
print('new')
local Item = workspace:WaitForChild(Speaker.Value):Clone()
Item.HumanoidRootPart.CFrame = CFrame.new(ViewportPoint)
Item.Parent = ViewportFrame
local cfrane,size = Item:GetBoundingBox()
local Max = math.max(size.X,size.Y,size.Z)
local Distance = (Max/math.tan(math.rad(ViewportCamera.FieldOfView))) * 1.5
local CurrentDistance = (Max/2) + Distance
ViewportCamera.CFrame = CFrame.new(ViewportPoint + Vector3.new(0,0,CurrentDistance),ViewportPoint)
end)
But it doesn’t work!
It should put the players character in a viewport.
Error:
Thanks for any help!