Hey, I’m new to scripting and was trying to make a custom main menu with a custom camera view. It is meant to view something in the menu and then when pressing the play button will get rid of the gui and put the camera back to normal. The local script for the camera is in the play button. I got it from a youtube video so it might not be that reliable. Here’s the code I was using:
local Camera = game.Workspace.CamPart
local Player = game.Workspace.LocalPlayer
local Players = game:GetService("Players")
local Camera = workspace.CurrentCamera
local CamPart = workspace:WaitForChild("CamPart")
local Player = Players.LocalPlayer
Player.CharacterAdded:Wait()
repeat wait() until Camera.CameraType == Enum.CameraType.Custom --wait for the CameraType to be set to Custom, otherwise setting it to anything else without this wouldn't work.
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CamPart.CFrame
script.Parent.Parent.Enabled = true
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Enabled = false
Camera.CameraType = Enum.CameraType.Custom
end)
Try removing the line repeat wait() until Camera.CameraType == Enum.CameraType.Custom --wait for the CameraType to be set to Custom, otherwise setting it to anything else without this wouldn't work.
from the script.
local Camera = workspace.CurrentCamera
local CamPart = workspace:WaitForChild("CamPart")
repeat wait() until Camera.CameraType == Enum.CameraType.Custom --wait for the CameraType to be set to Custom, otherwise setting it to anything else without this wouldn't work.
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CamPart.CFrame
script.Parent.Parent.Enabled = true
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Enabled = false
Camera.CameraType = Enum.CameraType.Custom
end)