Hey everyone!

I made a cutscene using TweenService and added a button. When this button is clicked, it should reset the camera to the player.

Button Code

local Camera = game.Workspace.CurrentCamera

function onClicked()
	print("resetting camera")
        wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	print("camera reset is done")
end

script.Parent.MouseButton1Click:Connect(onClicked)

Looks about right to me to be honest, but in the console, I keep getting the error:

"unable to index nil to Character"

Im confused about this as it had worked when i had done it without a button.

2 comments

0

The code is inside a localscript, right?

0

^ that fixed it, thanks