Camera script reverse to normal camera

Hi
I currently have this script

local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera

local defaultCFrame = camera.CFrame
local view = 150

function updateCamera()
	camera.CFrame = game.Workspace.HomeCamera.CFrame
end

game:GetService("RunService").RenderStepped:Connect(updateCamera)

How could I make it so it switches back to normal player camera after like… 3 seconds?
I tried searching the wiki and the forum, I got close but it seemed to be about something else.

Assuming you meant how to get the camera back to the player ( default settings ) then this is how you do it :

local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera

function setBackCamToPlr()
	warn("Setting camera back")
	camera.CameraType = Enum.CameraType.Custom
	local HUM = player.Character.Humanoid
	camera.CameraSubject = HUM
end

So now all you need to do is call the setBackCamToPlr Function whenever you want to set it back.

I implemented the script, and I got the warning but it did not change the camera.
Maybe it has something do do with the fact I used CFrame in the first function?

1 Like

Is you’re RenderStep Still running? I think you should Disconnect It if you want it to be set or else it would continue forever.

I put it like this

game:GetService("RunService").RenderStepped:Connect(updateCamera)
wait(2)
game:GetService("RunService").RenderStepped:Disconnect()
setBackCamToPlr()

but I got this error: “Disconnect is not a valid member of RBXScriptSignal”

This is what you need to do Instead :

local connection

connection = game:GetService("RunService").RenderStepped:Connect(updateCamera)
task.wait(2)
connection:Disconnect()
setBackCamToPlr()

God your a life saver thank you

1 Like

You’re very welcome, Enjoy and keep up the good work!

:Disconnect() is an instance method belonging to RBXScriptConnection objects.