I have a concept for a menu in mind and ran into some trouble. I have two blocks I'd like the camera to spin around, and when I click buttons, I wanted to make the camera smoothly go between each block and spin around the blocks.
Here is a video of what it does: https://streamable.com/9c1ipv I've tried everything and I don't know why it cuts like that. Here's my code for the camera spin:
plr = game.Players.LocalPlayer;
mouse = plr:GetMouse();
frame = plr.PlayerGui:WaitForChild("ScreenGui").Frame;
renderstepped = game:GetService('RunService').RenderStepped;
camera = workspace.CurrentCamera;
TweenService = game:GetService("TweenService");
camera.CameraType = Enum.CameraType.Scriptable;
camera.CameraSubject = workspace:WaitForChild("Camera Focus");
mouseButton = nil;
--CAMERA
rotationAngle = Instance.new("NumberValue")
tweenComplete = false
cameraOffset = Vector3.new(0, 5, 5)
rotationTime = 15 -- Time in seconds
rotationDegrees = 360
rotationRepeatCount = -1
lookAtTarget = true
target = workspace:WaitForChild("Camera Focus");
function spin()
camera.Focus = target.CFrame
rotatedCFrame = CFrame.Angles(0, math.rad(rotationAngle.Value), 0)
rotatedCFrame = CFrame.new(target.Position) * rotatedCFrame
camera.CFrame = rotatedCFrame:ToWorldSpace(CFrame.new(cameraOffset))
if lookAtTarget == true then
camera.CFrame = CFrame.new(camera.CFrame.Position, target.Position)
end
end
-- Set up and start rotation tween
tweenInfo = TweenInfo.new(rotationTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, rotationRepeatCount)
tween = TweenService:Create(rotationAngle, tweenInfo, {Value=rotationDegrees})
tween.Completed:Connect(function()
tweenComplete = true
end)
tween:Play()
-- Update camera position while tween runs
renderstepped:Connect(function()
if tweenComplete == false then
spin()
end
end)
--
Here's the buttons:
--camera manipulation and gui tween test
button = frame.Tween.TextButton;
button2 = frame.TweenB.TextButton;
clicked = false;
function buttonHandeler()
if clicked == false
then
clicked = true;
print(clicked)
for i,v in pairs(frame:GetChildren())
do
local function moveBack()
v:TweenPosition(UDim2.new(-.15,0,v.Position.Y.Scale,0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce,.8,false);
wait(1)
v:TweenPosition(UDim2.new(0,0,v.Position.Y.Scale,0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce,.8,false);
end
wait();
spawn(moveBack);
end
if mouseButton == button
then
--target = workspace:WaitForChild("Camera Focus B");
--lookAtTarget = false;
tweenComplete = true;
tween:Pause();
--camera.CFrame = rotatedCFrame:ToWorldSpace(CFrame.new(cameraOffset))
target = workspace["Camera Focus B"];
local localtween = TweenService:Create(camera,
TweenInfo.new(.7,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),
{CFrame = CFrame.new(camera.CFrame.Position, target.Position)});
localtween:Play();
wait(.7);
tween:Play();
tweenComplete = false;
--lookAtTarget = true;
else
--target = workspace:WaitForChild("Camera Focus B");
--lookAtTarget = false;
tweenComplete = true;
tween:Pause();
--camera.CFrame = rotatedCFrame:ToWorldSpace(CFrame.new(cameraOffset))
target = workspace["Camera Focus"];
local localtween = TweenService:Create(camera,
TweenInfo.new(.7,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),
{CFrame = CFrame.new(camera.CFrame.Position, target.Position)});
localtween:Play();
wait(.7);
tween:Play();
tweenComplete = false;
--lookAtTarget = true;
end
end
clicked = false;
end
button.MouseButton1Click:connect(buttonHandeler);
button2.MouseButton1Click:connect(buttonHandeler);
Kinda took a break for a while so my mind is a little rusty.

1 comment
Oh, cool, I don't know a bunch either :(