Why doesnt this work

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

i want to make the camera a certain cframe at start of game but it doesnt work

this is my code

repeat task.wait() until game:IsLoaded()

local cam = game:GetService("Workspace").CurrentCamera

cam.CameraType = Enum.CameraType.Scriptable

while task.wait() do
	cam.CFrame = CFrame.new(-18.3399105, 6.20346928, 29.3855038, 0.741993368, 0.0252662133, -0.669930935, 1.86264515e-09, 0.999289572, 0.0376878604, 0.670407236, -0.0279641449, 0.741466224)
end

Could you define what “doesnt work” in this question you are asking?

i tried checking if its the same, and it is but it wont show and would just show as if it was never changed

It’s probably because the CFrame you are attaching the camera to is already in the spot you desired to do. What the code is saying is to have this code put the camera in one position infinite amount of time. Do try printing something inside the while loop, however. I don’t think your while loop is running correctly.

its printing completely fine

ive used

repeat task.wait() until game:IsLoaded()

local cam = game:GetService("Workspace").CurrentCamera

cam.CameraType = Enum.CameraType.Scriptable

while task.wait() do
	if cam.CFrame == CFrame.new(-18.3399105, 6.20346928, 29.3855038, 0.741993368, 0.0252662133, -0.669930935, 1.86264515e-09, 0.999289572, 0.0376878604, 0.670407236, -0.0279641449, 0.741466224) then
		print("Test")
	end
	cam.CFrame = CFrame.new(-18.3399105, 6.20346928, 29.3855038, 0.741993368, 0.0252662133, -0.669930935, 1.86264515e-09, 0.999289572, 0.0376878604, 0.670407236, -0.0279641449, 0.741466224)
end

and it keeps printing “Test” but its bever shown in the actual game

this is why i left roblox studio for so long im literally changing it constantly but it never shows, if youre currently learning roblox studio, dont. Do unity or unreal instead.

I agree with you that roblox studio is… not the best, but working with CFrames is one of the world’s worst thing when it comes to roblox development.

I don’t understand it, but I would recommend just setting the CFrame of your camera to an invisible, collide off part to make It easier.

Can you maybe use the CFrame like this instead of writing so many things inside the CFrame.new()?

CFrame.new(Position, LookAtPosition)

I think it’s better if you do while true do, and add a wait right before that (and ofc make sure this is a local script to get the CurrentCamera)

repeat
    task.wait()
until game:IsLoaded()

local cam = game:GetService("Workspace").CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable

while true do
    wait(0.1) 
    cam.CFrame = CFrame.new(-18.3399105, 6.20346928, 29.3855038, 0.741993368, 0.0252662133, -0.669930935, 1.86264515e-09, 0.999289572, 0.0376878604, 0.670407236, -0.0279641449, 0.741466224)
end

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