How to access camera in startergui

I want to move a camera to a certain position when a gui is clicked

local cameras = game.Workspace.Cameras:GetChildren()

game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function (player, area)
	if area < #cameras then
		return cameras[area+1].Position
	end
end
local leftbutton = script.Parent
local area = 1

leftbutton.MouseButton1Click:Connect(function()
	local returnedvalue = game.ReplicatedStorage.RemoteFunction:InvokeServer(area)
	print(returnedvalue)
end)

I want the camera to move to ‘returnedvalue’ but camera doesnt work

1 Like

So to start first make a part where the camera will go to:


The Arrow shows the front of the part where the camera will face, use a decal to check
Then Make a Gui like this (U can change it however you like):

Then Make a script like this

(IT SHOULD BE A LOCAL SCRIPT INSIDE STARTER PLAYER SCRIPTS)

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local Gui = Player.PlayerGui:WaitForChild("Camera")

local Point = game.Workspace.CameraPoint

local Enabled = false

Gui.TextButton.MouseButton1Up:Connect(function()
	if Enabled then
		repeat Camera.CameraType = Enum.CameraType.Custom
		until Camera.CameraType == Enum.CameraType.Custom -- Makes it Normal
		Enabled = false
	else
		repeat Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable -- Makes Camera Scriptable
		Camera.CFrame = Point.CFrame -- Changes the position to parts CFrame
		Enabled = true
	end
end)

You can check if it works and also if you know how to use tween then You can use it on here as well.
Mark me as Solution :slight_smile:

2 Likes

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