Click Detector Wont set camera

I want to make it so when you click on a part it sets your camera to another part. This is the script I have that wont work.

local Player = game.Players.LocalPlayer

local Character = Player.Character

local Camera = workspace.CurrentCamera

function clicked()

Camera.CFrame = workspace.CameraParts.CamPart2.CFrame

end

game.Workspace.Planets.Coruscant.ClickDetector.MouseClick:Connect(clicked)

The thing is, I have this script inside of a GUI text button and it works fine, Please help.

1 Like

You need to set the CameraType to “Scriptable”, like this.

local function clicked()
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = workspace.CameraParts.CamPart2.CFrame
end

Make sure that the script is a LocalScript as well.

1 Like

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