CameraType.Custom wont work

I’m making a transformation script, and it works fine except for the camera part.

			camera.CameraType = Enum.CameraType.Scriptable
				camera.CFrame = cam.CFrame
		until camera.CameraType == Enum.CameraType.Custom
		end
		print("keycode")
		wait(3)
		cam:FindFirstChild("WeldConstraint").Part1 = nil
		cam.Anchored = true
		cam.CFrame = head.CFrame * CFrame.new(0,120,0) * CFrame.Angles(-95, 0, 0)
		wait(4)
		print("CUSTOM")
		camera.CameraType = Enum.CameraType.Custom
		print("HOORAY")
		cam:Destroy()
		print("loaded")
end)
end)

It says that Camera is being set back to custom, but when I play my camera just stays where i set it to and my character moves around without the camera.

1 Like

can you send the whole script pls

local player =  game.Players.LocalPlayer
player.CharacterAdded:Connect(function(character)
character.Archivable = true
local UIS = game:GetService("UserInputService")
local event = game.ReplicatedStorage:FindFirstChild("TitanShifting"):FindFirstChild("Titanshift")
local camera = game.Workspace.CurrentCamera
local head = character:WaitForChild("Head")

UIS.InputBegan:Connect(function(input)
	if input and input.KeyCode == Enum.KeyCode.P then
		event:FireServer(player)
		print("camera")
		character:FindFirstChild("Humanoid").WalkSpeed = 0
		character:FindFirstChild("Humanoid").JumpPower = 0
		character:FindFirstChild("Humanoid").AutoRotate = false
		repeat wait()
			camera.CameraType = Enum.CameraType.Scriptable
				camera.CFrame = head.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0, 185.35, 0)
		until camera.CameraType == Enum.CameraType.Custom
		end
		print("keycode")
		wait(2)
		print("CUSTOM")
		camera.CameraType = Enum.CameraType.Custom
		print("HOORAY")
		print("loaded")
end)
end)```

im prety new to script but i tryna help ppl if i can and if the problem is the repeat then do

until camera.CameraType == Enum.CameraType.Scriptable

because i can’t really see how can the camera become custom if you want it to be scriptable

make a pcall maybe it gonna work

It’s because your condition to end the repeat loop is the camera being set to normal when that never occurs.

Instead of using repeat if you want it to be a temporary loop you should use this instead

for i = 1,100 do -- change 100 to how long
game:GetService("RunService").RenderStepped:Wait()

--And the rest of your camera code within the repeat
end

pack the repeat loop into a thread so it doesn’t yield the code you need

task.spawn(function() -- or task.defer(), up to you
		repeat wait()
			camera.CameraType = Enum.CameraType.Scriptable
				camera.CFrame = head.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0, 185.35, 0)
		until camera.CameraType == Enum.CameraType.Custom
end)