Hello, when trying to achieve CFrame Tween for my loading screen I get the same error which I don’t know how to fix. Can anyone help?
My error:
The Script:
It says something is wrong within line 57. I’m not sure what it is… Help is very appreciated!
local camera = Instance.new("Camera", vf)
camera.FieldOfView = 40
local me = script.Parent.ViewportFrame["Put in"]
local s = script.Parent:WaitForChild("bass")
s:Play()
local base = me.Head.Position
local ba = me.Head.CFrame
local bos = script.Parent.Parent:WaitForChild("text").Position
local bo =script.Parent.ViewportFrame["Put in"].Head.Position
local n =0
local n2 =0
game:GetService("RunService").RenderStepped:Connect(function()
n = n+.07
n2 = n2-.14
local am = math.cos(n)
local am2 = math.cos(n2)*1.5
me:SetPrimaryPartCFrame(ba*CFrame.new(0,am2,0)* CFrame.Angles(0,math.rad(90),0) )
local cameraPosition = bo + Vector3.new(-3.5,0,am*2)
script.Parent.Parent:WaitForChild("text").Position = bos + UDim2.new(0,-am*200,0,am2*14-10)
camera.CFrame = CFrame.new(cameraPosition, me.Head.Position +Vector3.new(0,0,am/5))
script.Parent.ViewportFrame.CurrentCamera = camera
end)
function lerp(a, b, t)
return a * (1-t) + (b*t)
end
game:GetService("RunService").RenderStepped:Connect(function()
local now = lerp(workspace.Camera.FieldOfView,40- s.PlaybackLoudness/14,.3)
workspace.Camera.FieldOfView = now
end)
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera:Interpolate(workspace.Campost:FindFirstChild(1).CFrame,workspace.Campost:FindFirstChild(1).CFrame*CFrame.new(0,0,-1),.1)
while wait(1.5) do
for i = 1,13 do
wait(3)
workspace.CurrentCamera:Interpolate(workspace.Campost:FindFirstChild(i).CFrame,workspace.Campost:FindFirstChild(i+1).CFrame,4)
end
end
me.Parent:Destroy()