My camera wont rotate in this menu I am working on

Whatsup,

So I am working on a project and I wanted to create a main menu with a camera that keeps rotating.
The way I am doing it appears to not be working, could anyone give me a solution and possibly explain me how my code didn’t work?

So I made a block rotate and tried updating the camera’s orientation to match the rotation of that block.

Code client:

local mmCam = workspace.CurrentCamera

task.defer(function()
	if mmCam.CameraType ~= Enum.CameraType.Scriptable then
		repeat wait()
			mmCam.CameraType = Enum.CameraType.Scriptable
		until mmCam.CameraType == Enum.CameraType.Scriptable
	else
		mmCam.CFrame = game.Workspace.CameraMainPart.CFrame
		while task.wait() do
			mmCam.CFrame = CFrame.new(game.Workspace.CameraMainPart.CFrame.Position)*CFrame.Angles(game.Workspace.CameraMainPart.Orientation)
		end
	end
end)

code rotating part:

task.defer(function()
	while task.wait() do
		script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)
	end
end)

Nevermind, I already found a solution. I also compressed all of the code into the client sided script:

task.defer(function()
	local RotationalSpeed = 0.5
	local CameraPosition = Vector3.new(0,50,0)

	local Camera = game.Workspace.CurrentCamera

	local CameraSubjectPart = Instance.new("Part", game.Workspace)
	CameraSubjectPart.Name = "CameraMainPart"
	CameraSubjectPart.CanCollide = false
	CameraSubjectPart.Anchored = true
	CameraSubjectPart.Position = CameraPosition
	CameraSubjectPart.Size = Vector3.new(2,2,2)
	CameraSubjectPart.Transparency = 1


	repeat wait()
		Camera.CameraType = "Scriptable"
		CameraSubjectPart.Orientation = Vector3.new(0, CameraSubjectPart.Orientation.Y + RotationalSpeed, 0)
		Camera.CFrame = CFrame.new(0, CameraSubjectPart.Position.Y, 0) * CFrame.Angles(0,math.rad(CameraSubjectPart.Orientation.Y),0) 
	until script.Enabled == false -- Change the Enabled value to False anytime to stop rotation, and to clean up camera

	CameraSubjectPart:Remove()
	Camera.CameraType = "Custom" -- Default
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid",3)
end)

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