Resetting the camera back to the player's

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local run = game:GetService("RunService")

local cp = workspace:WaitForChild("Cam")
local cam = workspace.CurrentCamera
local maxDegree = math.rad(30)

local startergui = game:GetService('StarterGui')
local gui = startergui.WelcomeIntroGui

repeat
	cam.CameraType = Enum.CameraType.Scriptable
until 	cam.CameraType == Enum.CameraType.Scriptable

startergui.Dialog.Enabled = false
startergui.Stamina.Enabled = false
startergui.Blur.Disabled = true
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

run:BindToRenderStep("MenuCamera", 0, function()
	local np = Vector2.new(mouse.X, mouse.Y)
	local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
	local difference = np - centre

	local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)

	cam.CFrame = CFrame.Angles(-outcome.X, -outcome.Y,0) + cp.Position
end)
game.StarterGui.WelcomeIntroGui.Welcome.Play.MouseButton1Click:Connect(function()
	gui.Welcome.Play:TweenPosition(UDim2.new(0, 0,10, 0), 'Out', 'Linear', 1)
	
	startergui.Dialog.Enabled = true
	startergui.Stamina.Enabled = true
	startergui.Blur.Disabled = false
	startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	
	run:UnbindFromRenderStep("MenuCamera")
end)

I combined the two scripts, but I’m still confused on how to do the normal renderstep & disconnecting that.

Your script will never work it should be Player.PlayerGui.WelcomeIntroGui

Well, everything is breaking now. I don’t know what I did wrong but this is so frustrating. At this point, can I just hire you?

Try something like this making an actual connection to the render then disconnecting it when they click the mouse then set cam back to player using what you had above I put comments on everything I added or changed

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local run = game:GetService("RunService")

local cp = workspace:WaitForChild("Cam")
local cam = workspace.CurrentCamera
local maxDegree = math.rad(30)

local startergui = game:GetService('StarterGui')
local gui = startergui.WelcomeIntroGui

repeat
	cam.CameraType = Enum.CameraType.Scriptable
until 	cam.CameraType == Enum.CameraType.Scriptable

startergui.Dialog.Enabled = false
startergui.Stamina.Enabled = false
startergui.Blur.Disabled = true
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)


local RenderConnection = run.RenderStepped:Connect(function()  -- just make the connection like this and do disconnect below on mouse click its easier
	local np = Vector2.new(mouse.X, mouse.Y)
	local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
	local difference = np - centre

	local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)

	cam.CFrame = CFrame.Angles(-outcome.X, -outcome.Y,0) + cp.Position
end)

game.StarterGui.WelcomeIntroGui.Welcome.Play.MouseButton1Click:Connect(function()
	RenderConnection:Disconnect()  -- when they hit the button disconnect the connection 
	wait()
	cam.CameraSubject = player.Humanoid   -- set the cam back to the player with these 2
	cam.CameraType = Enum.CameraType.Custom 
	
	gui.Welcome.Play:TweenPosition(UDim2.new(0, 0,10, 0), 'Out', 'Linear', 1)

	startergui.Dialog.Enabled = true
	startergui.Stamina.Enabled = true
	startergui.Blur.Disabled = false
	startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
end)

I messed with the script and gui a bit, and I ended up fixing it. Thanks to everyone who tried to help me.

To anyone interested, here is the fixed script:

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local run = game:GetService("RunService")

local cp = workspace:WaitForChild("Cam")
local cam = workspace.CurrentCamera
local maxDegree = math.rad(30)

local startergui = game:GetService('StarterGui')
local button = script.Parent

repeat
	cam.CameraType = Enum.CameraType.Scriptable
until 	cam.CameraType == Enum.CameraType.Scriptable

startergui.Dialog.Enabled = false
startergui.Stamina.Enabled = false
startergui.Blur.Disabled = true
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)


local RenderConnection = run.RenderStepped:Connect(function()  -- just make the connection like this and do disconnect below on mouse click its easier
	local np = Vector2.new(mouse.X, mouse.Y)
	local centre = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
	local difference = np - centre

	local outcome = Vector2.new((difference.Y/centre.Y)*maxDegree, (difference.X/centre.X)*maxDegree)

	cam.CFrame = CFrame.Angles(-outcome.X, -outcome.Y,0) + cp.Position
end)

button.MouseButton1Click:Connect(function()
	button:TweenPosition(UDim2.new(0, 0,1, 0), 'Out', 'Linear', 1)
	RenderConnection:Disconnect()  -- when they hit the button disconnect the connection 
	wait()
	cam.CameraSubject = player.Humanoid   -- set the cam back to the player with these 2
	cam.CameraType = Enum.CameraType.Custom 

	startergui.Dialog.Enabled = true
	startergui.Stamina.Enabled = true
	startergui.Blur.Disabled = false
	startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
end)

If anyone wants to use it, it should be pretty simple to set up. Just make sure everything matches up. And again, thanks for the help.

1 Like