Bug in my script for showing a view from a camera until the play button is pressed

I have a script for my play button screen that shows a view from a brick called CameraPos until the button is pressed. However, the camera sometimes goes back to where the player died instead of following the player after pressing play.
Localscript in startergui:

local character = player.Character

local camera = workspace.CurrentCamera

repeat wait()

camera.CameraType = Enum.CameraType.Scriptable

until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = workspace.CameraPos.CFrame```
Script inside button:
 script.Parent.Parent.Enabled = false
 workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
 workspace.CurrentCamera.Blur.Enabled = false

You have to change the CameraSubject as well.

-- Script inside button
	script.Parent.Parent.Enabled = false;
	workspace.CurrentCamera.CameraSubject = character.Humanoid;
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom;
	workspace.CurrentCamera.CFrame = character.Head.CFrame;

Also, you should probably read this post on why you shouldn’t use wait(). Try using game:GetService("RunService").Heartbeat:Wait() instead.

I will look into this. Thank you.

1 Like

It turns out that this script doesn’t work. It closes the guis but the camera gets stuck on where the view is and doesn’t switch to the player. The piece that is being looked through is called CameraPos btw.