What do I want to achieve? I customized a specific camera angle for the “opening menu” of a game I am making. I now want to continuously rotate the camera along a fixed point, in order to get the effect of a rotating game menu.
What is the issue? I have tried various different scripts, each somewhat accomplishing what I need. I have attempted to use while loops and tweenservice, each to no avail. Below are videos of both of the scripts and how they function.
This code sits atop both of the scripts I have tried:
local tweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
game.Workspace.Camera.CoordinateFrame = CFrame.new(character.HumanoidRootPart.Position + Vector3.new(0, 8, 12)) * CFrame.Angles(math.rad(-37), 0, 0)
game.Workspace.Camera.CameraSubject = humanoid
This is to lock the camera in a position I want.
Here is my TweenService script and accompanying video:
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local camera = workspace.Camera
print(camera.CFrame)
local target = camera.CFrame * CFrame.new(0, 0, 10) * CFrame.Angles(math.rad(-28.125), math.rad(180), math.rad(0))
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(camera, tweenInfo, {CFrame = target})
tween:Play()
Tween example.wmv (544.4 KB)
Here is my while loop attempt alongside the video:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local angle = 0
while true do
angle = angle + math.rad(1)
local target = camera.CFrame.p + Vector3.new(10 * math.cos(angle), 0, 10 * math.sin(angle))
camera.CFrame = CFrame.new(target, camera.CFrame.p) * CFrame.Angles(0, angle, 0)
wait()
end
robloxapp-20230208-0324105.wmv (747.6 KB)
The while loop example accomplishes the general idea of what I want. However, it moves too quickly and does NOT focus on a fixed point. Any help is appreciated, thank you.