Change between camera systems

Hello everyone!

I succesfully put a camera system in my ‘experience’ where the camera is above the player and when you move your mouse cursor, it goes off a bit. It is like a top-down 2d game ish. But I have a little problem; when the player walks into a part (for me a door part), they teleport into a different room. There, I want to change my camera from my normal top down view into a static camera in the room, as a part. I already have a system for a static camera, but I am not succesful in changing between the camera systems.

This is the system I use for my topdown view, in a localscript put into StarterCharacterScripts.

local Player = game:GetService("Players").LocalPlayer	
local player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local screenGui = game.StarterGui.ScreenGui

local Distance =,20,0) 
local Direction =,-1,0)
local CameraSensitivity = 10 

function getMouseScreenPositionCentered() 
		mouse.X - screenGui.AbsoluteSize.X/2,
		mouse.Y - screenGui.AbsoluteSize.Y/2)

function pixelToFraction(pixelV2)
		return pixelV2 / screenGui.AbsoluteSize

function onRenderStep() 	
	if player.Character then
		local rootPart = player.Character.HumanoidRootPart
		local playerposition = player.Character.HumanoidRootPart.Position +,0,3)

		local cameraoffset = Distance + playerposition

		local mouseScreenPos = pixelToFraction( getMouseScreenPositionCentered() )
		local Axis =,0,mouseScreenPos.X)

		local cameraPos = cameraoffset + Axis * CameraSensitivity 

		camera.CFrame =, cameraPos + Direction)

runService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

This is the system I made for my static camera view, normally put into a localscript put into StarterPack (or StarterCharacterScripts).

local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera

	local camera = workspace.CurrentCamera
	local Run = game:GetService("RunService")
	local part = workspace.CameraBlue 
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CameraSubject = part
	camera.FieldOfView = 45

	local function OnChanged()
		camera.CFrame = part.CFrame

And this is the script for when the part is touched, the player is teleported. In that script I want to change the camera system to a part inside the room where the camera needs to be, stated as ‘camerapart.Position’.

local TeleportPosition = script.Parent.Parent.TeleportPart
local camerascript = game.StarterPack.LobbyCameraScript
local topdownscript = game.StarterPlayer.StarterCharacterScripts.TopView

	if hit.Parent:FindFirstChild("Humanoid") then 
		if game:GetService("Players"):FindFirstChild(hit.Parent.Name) then 
				game:GetService("Players"):GetPlayerFromCharacter(hit.Parent).Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPosition.CFrame 
				local camerapart = workspace.CameraBlue -- the part in the workspace that is the camera view in the static view localscript
				camerapart.Position =, -4.426, -142.563) -- the position of the part in the room as stated above the script

If someone would be able to help me with changing between the two systems (to static and back to top view), you would be my hero at the moment. Maybe I am making it too difficult and is it not possible to make a switch between the two, I am a bit confused. Thanks for reading and hopefully replying. :grin:


1 Like