Can't teleport to custom camera / script wont work

Here is my Local Script in my StarterPlayerScripts,

i want it to teleport the player/the players screen to my custom part that i have named “DalgonaTriangleCam” Like a camera, Im new to making cameras but i saw a youtube video that used a part like a camera, please help.

/ Im making it so that when you stay on a part until a timer turns to 0, then it teleports your screen to a part that im using as a camera.

local camera = workspace.CurrentCamera  -- Player's active camera
local cameraPart = workspace.Cameras:WaitForChild("DalgonaTriangleCam")  -- The part acting as the camera
local timerTextLabel = game.StarterGui.DalgonaGame.TimerExtra  -- Timer UI

-- Listen for changes to the timer
timerTextLabel:GetPropertyChangedSignal("Text"):Connect(function()
	if timerTextLabel.Text == "0" then
		print("Timer hit 0! Switching to DalgonaTriangleCam.")

		-- Switch the player's view to the part
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = cameraPart.CFrame
		print("Camera teleported to DalgonaTriangleCam.")

		-- Return to normal view after 10 seconds
		task.delay(10, function()
			camera.CameraType = Enum.CameraType.Custom
			print("Returned to normal camera.")
		end)
	end
end)
6 Likes

Camera is always automatically updated by the core scripts. if you need to set it’s position, then you need to constantly update it in RenderStepped

something between the lines of:

local RunService = game:GetService("RunService")

local cam = workspace.CurrentCamera
RunService.RenderStepped:Connect(function(dt)
   cam.CFrame = CFrame.new()
end)

where should i put this, in my script or another one and where in my script?

1 Like
local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera  -- Player's active camera
local cameraPart = workspace.Cameras:WaitForChild("DalgonaTriangleCam")  -- The part acting as the camera
local timerTextLabel = game.StarterGui.DalgonaGame.TimerExtra  -- Timer UI
local function updateCam()
	camera.CFrame = cameraPart.CFrame
end
-- Listen for changes to the timer
timerTextLabel:GetPropertyChangedSignal("Text"):Connect(function()
	if timerTextLabel.Text == "0" then
		print("Timer hit 0! Switching to DalgonaTriangleCam.")
		-- Switch the player's view to the part
		local event = RunService.RenderStepped:Connect(updateCam)
		

		-- Return to normal view after 10 seconds
		task.delay(10, function()
			event:Disconnect()
			print("Returned to normal camera.")
		end)
	end
end)

it doesnt teleport me anywhere or print anything, Could you take a look in studio if i invited you tysm

If it doesn’t print, then there is something off with your script that controls timerTextLabel. Check the script that controls it and see if it ever changes the value to 0

could u take a look for me in roblox studio? i have everything organized and it would help me out a lot if i invited you, could you take a look for me 2 minutes? Is that okay? Ive been stuck on this the entire day and im really tired out

can u do that? it will help me out so much