Cant seem to set camera cframe

Im trying to set the camera to scriptable but too no avail any reasons why its not working, ive tried methods that I know of still doesnt want to work

local function setCFrame(cframe)
	repeat camera.CameraType = Enum.CameraType.Scriptable
		
	until camera.CameraType == Enum.CameraType.Scriptable
	camera.CFrame = cframe
end
setCFrame(game.Workspace.Dummy.Head.CFrame)

Alright I just tried that and it still doesnt seem to be working, and also it actually is setting it in the loop its repeating setting the camera type

1 Like

How are you defining the camera, and where is this code located?

Its located in a local script and im defining the camera earlier in the code I just never showed it

local plr = game.Players.LocalPlayer

--- Camera
local camera = game.Workspace.CurrentCamera

--- UI Oriented Stuff
local Event = plr.PlayerGui:WaitForChild("Event")
local mainMenu = Event.mainMenu

--- main menu Buttons
local play = mainMenu.play
local settingz = mainMenu.settings

local Design = require(game.ReplicatedStorage.Design)
local Functions = Design.new()
Functions:Enter(play)
Functions:Enter(settingz)
Functions:AddBlur(camera)

local function setCFrame(cframe)
	repeat camera.CameraType = Enum.CameraType.Scriptable
		
	until camera.CameraType == Enum.CameraType.Scriptable
	camera.CFrame = cframe
end
setCFrame(game.Workspace.Dummy.Head.CFrame)

Are you defining it as workspace.CurrentCamera? Where is the LocalScript located?

The local script is located in startergui and I thought that Workspace and workspace were basically interchangeable??

Try doing camera.CameraSubject = nil before setting the camera type to scriptable

workspace is a shortcut for game.Workspace. You can’t just use Workspace though, since you are accessing it as a service.

I thought you said you were using Workspace.CurrentCamera, instead of workspace.CurrentCamera.

Yeah thats why I said there interchangable, you made it seem as if that was the problem

1 Like

I just tried that and to no avail and its still not working, thanks for your contribution though

What exactly is your use case? Do you want the camera to stay locked in your CFrame until released?

I think its pretty obvious what im trying to do from my post im trying to set it to scriptable then set its cframe

To make sure that it really isn’t changing, can you try putting

print(camera.CameraType)

at the end of your setCFrame function to make sure it does indeed print Custom?

It says its set to scriptable… : D
image

What caused you to think it was not changing?

Well it still doesnt want to set my cameras CFrame for some odd reason

It’s not obvious. The only thing that’s obvious is that you want the camera to be in a certain CFrame, but that doesn’t explain your use case at all. When do you want to release it? Do you want to update it? Do you want it to change at all after setting the CFrame?

local function setCFrame(cframe)
	local c c = game:GetService("RunService").RenderStepped:Connect(function() camera.CFrame = cframe end)
    return function() c:Disconnect() end
end

Main thing is it still doesnt want to set the cframe of the camera even though its scriptable

You got any output errors by any chance?

it goes through all the code inside of the function and prints out that it turned scriptable, problem is it just still doesnt want to ste the cframe of the camera, im not sure why because it printed that it was scriptable