This only runs once. Please help

Hello! I created an advanced camera system, however, it only runs once.

local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()

local OutdoorCamera
local GoingInsideCamera

local function CreateOutdoorCamera()
	local offset = Vector3.new(0, 0, 30)
	local FOV = 35
	Camera.FieldOfView = FOV
	OutdoorCamera = RunService.RenderStepped:Connect(function()
		local PlayerPosition = Character.HumanoidRootPart.Position
		local CameraPosition = PlayerPosition + offset
		Camera.CoordinateFrame = CFrame.new(CameraPosition, PlayerPosition)
	end)
end

game.ReplicatedStorage.DoCamera.OnClientEvent:Connect(function(TheCamera, Door, doCFrame)
	if TheCamera == "Stick" then
		local CameraCFrame = Camera.CFrame
		OutdoorCamera:Disconnect()
		GoingInsideCamera = RunService.RenderStepped:Connect(function()
			Camera.CFrame = CameraCFrame
		end)
	elseif TheCamera == "Fixed" then
		GoingInsideCamera:Disconnect()
		OutdoorCamera:Disconnect()
		Camera.FieldOfView = 70
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CameraSubject = Door
		if doCFrame == true then
			Camera.CFrame = Door.CFrame
		end
	else
		CreateOutdoorCamera()
	end
end)

CreateOutdoorCamera()

Everything works only once, then you have to rejoin the game.
If you can help, please let me know. Thanks! WE

1 Like

How do you expect it to run multiple times when your calling it once.

1 Like

Is this script parented to StarterCharacterScripts?
If its not it most definitely wont run for more than one life, if thats what you mean when you say “it only runs once”

2 Likes

Wait I am confused? I am firing game.Rep.DoCamera:FireClient(Player, the parms)

1 Like

Yes. It is parented in StarterCharacterScripts.

1 Like

And then it will only run once again once you fire it.

1 Like

Well it is not working the second time after firing.

1 Like

Oh my bad I read the code wrong. It won’t work the second time because your disconnecting the RunService event.

1 Like

Would I need to set the variable to nil after disconnecting it?

1 Like