So i have this camera script that will make change Player Camera CFrame to the selected object. In studio they works properly but when tried in Roblox itself its not working and just yield me an error "Infinite yield possible on "workspace:WaitForChild(“MenuFocus”). And yes the object exist there
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local mainMenuCam = game.Workspace.GameMap:WaitForChild("CameraValue")
local TS = game:GetService("TweenService")
local playergui = player.PlayerGui
coroutine.wrap(function()
while task.wait(35) do
local Tween = TS:Create(playergui.MainGui.MainMenuFrame,TweenInfo.new(2.5),{BackgroundTransparency = 0})
local Tween2 = TS:Create(playergui.MainGui.MainMenuFrame,TweenInfo.new(2.5),{BackgroundTransparency = 1})
Tween:Play()
Tween.Completed:Wait()
task.wait(.5)
if mainMenuCam.Value == "MenuFocus" then
mainMenuCam.Value = "MenuFocus2"
elseif mainMenuCam.Value == "MenuFocus2" then
mainMenuCam.Value = "MenuFocus3"
elseif mainMenuCam.Value == "MenuFocus3" then
mainMenuCam.Value = "MenuFocus"
end
task.wait(.5)
Tween2:Play()
end
end)()
task.wait(5)
while task.wait() do
print(mainMenuCam.Value)
local menupart = workspace:WaitForChild(mainMenuCam.Value)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = menupart.CFrame
end