Need help in studio on how to teleport the players camera

What ive been trying to script for almost 2 days now, Is a Local Script in StarterPlayerScripts is this: A player has 15 seconds to enter a Area (Go inside a part) and when the 15 sec timer hits 0, The player’s camera or screen teleports to a specific part that im using as a camera.

The timer works and its not related to this script but when the timer hits 0 and im in the area nothing happens and it doesnt teleport me.

/ PLEASE IF ANYONE HAS TIME THEN PLEASE LET ME KNOW AND ILL INVITE YOU TO MY GAME IN STUDIO AND PLEASE HELP ME TAKE A LOOK FOR JUST 5 MINUTES MAX, I would be extremely grateful and its a lot for me because if i dont solve this detail then i can’t continue with my game wich is really important

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)
3 Likes

PLEASE if anyone could spare 2-5 minutes taking a look at this your an angel thank you so much, im active a lot and might answer you directly, i have time from now and a few more hours

You added some prints there. Are there any that didn’t print in the console?

2 Likes

Nope it doesnt even print, My game is extremely organized and its not a lot of stuff if you wanted to take a look, You would really help me so much,

even chatGPT the 4o version couldn’t help after multiple tries, i tried to change the script like 30 times, and of course check the parts location etc

1 Like

So none of the prints are in the output? That can mean that the
GetPropertyChangedSignal didn’t fire OR the first condition did not pass.

You can add a print before the condition and see if it outputs in the console. This would identify if the event is being fired or not.

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()
	print("Event fired")
	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)
1 Like

Hard to test this, not everything is here to work with. However I do see a logic error that may be the main problem. You’re calling StarterGui and that is just a spot where them scripts get cloned to the players actual Gui folder in PlayerGui.

A quick guess …

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local cameraPart = workspace.Cameras:WaitForChild("DalgonaTriangleCam")
local timerTextLabel = player:WaitForChild("PlayerGui"):WaitForChild("DalgonaGame").TimerExtra

timerTextLabel:GetPropertyChangedSignal("Text"):Connect(function()
	if timerTextLabel.Text == "0" then
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = cameraPart.CFrame

		task.delay(10, function()
			camera.CameraType = Enum.CameraType.Custom
		end)
	end
end)
1 Like

I didn’t seem to notice that, and that may actually be the problem. There are no UI changes and updates inside the StarterGui, as it is just a container. The real UI changes are done in the Player’s PlayerGui, which is inside the Player object.

1 Like

My bad, posted to the wrong guy again. Ya, that may not be all the problems but that is a logic error.

OH MY GOD… Have a great day thank u so much

1 Like

I think we all have made that mistake at one time.

This may be problematic also;
if timerTextLabel.Text == “0” then

I like to call checks like that this way;
if tonumber(timerTextLabel.Text) < 1 then

Depending on how the timer is counting down, it may just go right past your check and, due to timing, miss it altogether. The < will catch that.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.