Main menu camera sway not working?

So I recently found a camera sway script and it works fine, but theres some things wrong with it, firstly, theres a quick second where the camera “positions” itself in the right position

(example)

https://gyazo.com/0ff08d7a17ae4557d5e3819aae3cbbee

and i was just wondering if there was a solution?

local LocalPlayer = game:GetService("Players").LocalPlayer;

local UserInputService = game:GetService("UserInputService");

local CurrentCamera = workspace.CurrentCamera;

local MainScreen = workspace:WaitForChild("Cameras"):WaitForChild("CameraPart")

local v1 = CFrame.Angles(0, 0, 0);

local RunService = game:GetService("RunService");

local ms = MainScreen;

CurrentCamera.CFrame = game.Workspace.Cameras:WaitForChild("CameraPart").CFrame

local u1 = 0;

local u2 = 0;

local u3 = 0;

local u4 = 0;

local u5 = v1;

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, function()

u1 = CurrentCamera.ViewportSize.X;

u2 = CurrentCamera.ViewportSize.Y;

if u3 == 0 and u4 == 0 then

local v36 = 0;

local v37 = 0;

else

v36 = u3 / u1 - 0.5;

v37 = u4 / u2 - 0.5;

end;

u5 = CFrame.Angles(-math.rad(v37 * 6), -math.rad(v36 * 5.5), 0);

CurrentCamera.CoordinateFrame = CurrentCamera.CoordinateFrame:lerp(ms.CFrame * CFrame.new(0, 0, -12) * CFrame.Angles(0, math.rad(180), 0) * u5, 0.04);

CurrentCamera.CameraType = Enum.CameraType.Scriptable;

end);

UserInputService.InputChanged:connect(function(p7, p8)

if p7.UserInputType == Enum.UserInputType.MouseMovement then

u1 = CurrentCamera.ViewportSize.X;

u2 = CurrentCamera.ViewportSize.Y;

u3 = math.max(0, math.min(p7.Position.X, u1));

u4 = math.max(0, math.min(p7.Position.Y + 36, u2));

end;

end);
2 Likes

Well, it seems like you forgot to set the camera type to scriptable. You should set the CameraType to scriptable before you script its CFrame and make sure to set the CameraType back to Custom once you’re done.

I think its something when its posiitoning the camera that makes it so far back, my camera part is here

but I have to put it so far up because it goes back like that

Well you never know until you try it.

I added it but it still does the same thing

From my experience lerping will move the camera from the player camera original position to the start position then it’ll go through your lerp.