Help with menu camera

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

repeat wait() until Player.Character

Camera.CameraType = “Scriptable”
Camera.CFrame = game.Workspace.CamPart.CFrame

script.Parent.Parent.Enabled = true

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Enabled = false
Camera.CameraType = “Custom”
end)

Any help to make this work would be highly appreciated.

I think u just need to change the “Camera” variable to:

local Camera = game.Workspace.CurrentCamera

Try this (I optimized your code too)

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)
1 Like

I tried it, still doesn’t work, thanks for trying though.

Is the script in PlayerGui and is it a LocalScript?

It’s in starter gui and it’s a local script inside the play button

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.

Still isn’t working, probably something wrong on my end

Let me try this myself and I’ll get back with you as soon as possible.

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)

This should work.

Dosen’t work 100% but the play button works now which is great, camera is still broke though

Hmm…

Try adding

Camera.Focus = Camera.CFrame

below

Camera.CFrame = CamPart.CFrame

and see if that works.

Nope, still not working. I am pretty clueless

So am I.

It should’ve worked because it did for me. Odd. Probably something on your end.

Yeah, thanks so much for the help though

1 Like

This script should work.

Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")