Why is my camera script not working?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Make the camera go to a player after a player presses play

  2. What is the issue? Its not working

  3. What solutions have you tried so far? Youtube

Here is my Camera script

wait(0.01)
local cam = game.Workspace.CurrentCamera
local CutOne = game.Workspace.IntroCutscene.CutOne
local Focus = game.Workspace.IntroCutscene.CutOneFocus
local player = game.Players.LocalPlayer
cam.CameraType = "Scriptable"
cam:Interpolate(CutOne.CFrame, Focus.CFrame,0.01)
wait(2)
game.StarterGui.Play.Design.PlayButton.MouseButton1Click:Connect(function()


	cam.CameraSubject =  player.Character.Humanoid
	cam.CameraType = "Custom"
end)

Here is the error image

1 Like

I’ve mentioned it way too much times, but this warning happens cause you’re changing the CameraType as the same time you’re referencing/getting the Camera

Before you even change your CameraType, add a wait() to fix it

Also you’re getting the StarterGui which is replicated only to the server

local cam = game.Workspace.CurrentCamera
local CutOne = game.Workspace.IntroCutscene.CutOne
local Focus = game.Workspace.IntroCutscene.CutOneFocus
local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local PlayButton = PlayerGui:WaitForChild("Play"):WaitForChild("Design"):WaitForChild("PlayButton")

wait() --Put it here cause ROBLOX is fun
cam.CameraType = "Scriptable"
cam:Interpolate(CutOne.CFrame, Focus.CFrame,0.01)

PlayButton.MouseButton1Click:Connect(function()
	cam.CameraSubject =  player.Character.Humanoid
	cam.CameraType = "Custom"
end)

2 Likes

Thank you so much! I have struggling with this for a while.

1 Like