So I have this local script that makes the camera move slightly with the cursor on the main menu of my game, but when I click the play button on my main menu the camera does not return to the player and to default gameplay like it's supposed to, and instead stays stuck at the same position. Does anyone know how I can fix this so that when the play button is clicked the camera goes back to normal on the player and the camera no longer moves slightly with the cursor?
Local Script for camera on main menu:
local cam = workspace.CurrentCamera
local camPart = workspace["CameraPart"]
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
repeat
wait()
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
local maxTilt = 10
game:GetService("RunService").RenderStepped:Connect(function()
cam.CFrame = camPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
Local Script Play Button Clicked:
playbtn.MouseButton1Click:Connect(function()
repeat wait()
camera.CameraType = Enum.CameraType.Custom
until camera.CameraType == Enum.CameraType.Custom
end)

2 comments
You're repeating yourself. You got an answer in the form of a comment the last time you asked. But you removed it. Someone told you to disconnect the RenderStepped function
I know, but I didn't know how to do that, so I thought by re-posting this they or someone else could help out, I'm sorry if I did anything wrong