I’ve looked everywhere and tried everything I could find and finally got to what is in the script below, but when the camera revolves, it’s inside of the gray part and is in the exact center of the room when I want it to be revolving around the part. I’m not sure how to offset the camera so it isn’t in the center but looking at the center.
Also, when I press the play button, it stops the tween and rotation, but the camera doesn’t return back to the player like normal. It stays inside the part and in the center of the room.
Here’s the localscript I have inside the title screen GUI
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.Camera
local Looping = true
local CameraSubjectPart = game.Workspace:WaitForChild("TitleCam") --Gray part in center of room
local RotationLength = 15
repeat wait() until Camera.CameraSubject ~= nil
Camera.CameraType = Enum.CameraType.Attach
Camera.CameraSubject = CameraSubjectPart
script.Parent.Parent.Enabled = true
local Info = TweenInfo.new(RotationLength, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local RotateTween = TweenService:Create(CameraSubjectPart, Info, {CFrame = CameraSubjectPart.CFrame * CFrame.Angles(0, math.rad(-120), 0)})
local Camera = game.Workspace.Camera --When the play button is clicked it stops the rotation
script.Parent.Play.MouseButton1Click:Connect(function()
Camera.CameraType = Enum.CameraType.Custom
script.Parent.Parent.Enabled = false --The ScreenGui (Title screen) goes away
Looping = false
RotateTween:Pause()
end)
while Looping do
if not Looping then return end
RotateTween:Play()
wait(RotationLength)
end
For this I wouldn’t recommend using Tweens, since you can’t really tween a revolving object or a circular motion at all.
One method I would use, a little inefficient, but here’s some code:
repeat wait() until Camera.CameraSubject ~= nil
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = CameraSubjectPart
script.Parent.Parent.Enabled = true
local PlayButtonClicked = false
local Radians = 0
local RS = game:GetService("RunService")
repeat
Radians = Radians + 1 -- edit the 1 to increase the speed
if Radians >= 360 then
Radians = 1
end
local OriginCF = CameraSubjectPart.CFrame * CFrame.Angles(0,math.rad(Radians),0)
local RevolvePosition = OriginCF + OriginCF.LookVector * 10 -- edit the 10 for distance from the object
Camera.CFrame = CFrame.new(RevolvePosition.Position, CameraSubjectPart.Position)
RS.RenderStepped:Wait()
until PlayButtonClicked == true
Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
So I’m not sure what to do about that. I think it might be because of the values in CFrame.new because I changed it to Vector3.new and it told me to change it back to CFrame.
Thanks, that fixed it. But, when I press the play button I change the camera back to custom like this:
Camera.CameraType = Enum.CameraType.Custom
But the camera just goes inside the CameraSubjectPart instead of the player. Is it because the CameraSubject is still set to that part? If so how would I change it to focus back on the player?