Hi, I’m having trouble with some code I made for my friends game. The menu has interchanging cameras, with basic gui. The problem is when I press Play. It doesn’t work. Here’s the code
local content = script.Parent.Content
local cameras = workspace.Cameras
local Camera = workspace.CurrentCamera
local DefaultCFrame = cameras.MainCamera.CFrame
local ts = game:GetService("TweenService")
local tweeninf = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local function Tween(obj, val)
local tween = ts:Create(obj,tweeninf,{BackgroundTransparency = val})
tween:Play()
tween.Completed:Wait()
end
repeat
wait()
Camera.CameraType = Enum.CameraType.Scriptable
until
Camera.CameraType == Enum.CameraType.Scriptable
Camera.FieldOfView = 50
while true do
Camera.CFrame = cameras.MainCamera.CFrame
Tween(content, 1)
wait(10)
Tween(content, 0)
Camera.CFrame = cameras.ChangeCamera.CFrame
Tween(content, 1)
wait(10)
Tween(content, 0)
Camera.CFrame = cameras.ChangeCamera2.CFrame
Tween(content, 1)
wait(10)
Tween(content, 0)
end
local title = script.Parent.Frame
local holder = script.Parent.ButtonHolder
script.Parent.ButtonHolder.Play.Activated:Connect(function()
script.Parent.sound:Play()
title:TweenPosition(UDim2.new(0.5, 0, 3, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
holder:TweenPosition(UDim2.new(0.5, 0, 4, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
wait(1.5)
Camera.CameraType = Enum.CameraType.Custom
Camera.FieldOfView = 70
title:Destroy()
content:Destroy()
script.Parent.Enabled = false
script:Destroy()
end)
It may have something to do with the loop, but I’m not sure. How do I fix this? And what would you recommend to be the best alternative for the loop?