How best to rotate the camera 360 degrees around the player?

Hello. I’m trying to rotate the camera around the player. Here is an example of a script that I wrote, but it doesn’t work very well.

cam.CameraType = Enum.CameraType.Custom

TweenService:Create(cam,TweenInfo.new(10),{CFrame = cam.CFrame*CFrame.Angles(math.rad(0),360,0)}):Play()
TweenService = game:GetService("TweenService")

Fix

local TweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")

-- Ensure the camera type is Scriptable for custom manipulation
cam.CameraType = Enum.CameraType.Scriptable

-- Function to rotate the camera around the player
local function rotateCamera(duration)
    local initialCFrame = cam.CFrame
    local goalCFrame = initialCFrame * CFrame.Angles(0, math.rad(360), 0)

    local tween = TweenService:Create(cam, TweenInfo.new(duration), {CFrame = goalCFrame})
    tween:Play()
end

-- Set the camera position relative to the player's root part
cam.CFrame = CFrame.new(rootPart.Position + Vector3.new(0, 5, 10), rootPart.Position)

-- Rotate the camera around the player over 10 seconds
rotateCamera(10)

The script doesn’t work. The camera just hangs in the air

If it still hangs in the air try this

local TweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")

-- Ensure the camera type is Scriptable for custom manipulation
cam.CameraType = Enum.CameraType.Scriptable

-- Function to rotate the camera around the player
local function rotateCamera(duration)
    local initialCFrame = cam.CFrame
    local goalCFrame = initialCFrame * CFrame.Angles(0, math.rad(360), 0)

    local tween = TweenService:Create(cam, TweenInfo.new(duration), {CFrame = goalCFrame})
    tween:Play()
end

-- Function to continuously update the camera's position relative to the player's root part
local function updateCameraPosition()
    local runService = game:GetService("RunService")
    runService.RenderStepped:Connect(function()
        cam.CFrame = CFrame.new(rootPart.Position + Vector3.new(0, 5, 10), rootPart.Position)
    end)
end

-- Set the initial camera position relative to the player's root part
cam.CFrame = CFrame.new(rootPart.Position + Vector3.new(0, 5, 10), rootPart.Position)

-- Start rotating the camera around the player over 10 seconds
rotateCamera(10)

-- Continuously update the camera's position relative to the player's root part
updateCameraPosition()

No. It still doesn’t work. How can I attach TweenServis to an object?

local cam = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")

-- Ensure the camera is in custom mode
cam.CameraType = Enum.CameraType.Custom

-- Define the TweenInfo
local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1)

-- Create the rotation CFrame
local rotation = CFrame.Angles(0, math.rad(360), 0)

-- Tween the camera
local tween = TweenService:Create(cam, tweenInfo, {CFrame = cam.CFrame * rotation})

-- Play the tween
tween:Play()

didnt i tell you to stop giving people ai ahh responses

download

I don’t understand how this works at all. I just want someone to tell me how to make the camera rotate around the player