Script changes the position of the camera

Heya there, fellow developers!
Today I found this thread, and I tried the solution. It works, but it shows the skybox instead of my scene.

Script
local Mouse = game.Players.LocalPlayer:GetMouse()

local Camera = game.Workspace.CurrentCamera

local DefaultCFrame = Camera.CFrame

local Scale = 200

game:GetService("RunService").RenderStepped:Connect(function()

Camera.Focus = DefaultCFrame

local Center = Vector2.new(Camera.ViewportSize.X/0.1, Camera.ViewportSize.Y/0.1)

local MoveVector = Vector3.new((Mouse.X-Center.X)/Scale, -(Mouse.Y-Center.Y)/Scale, 0)

Camera.CFrame = DefaultCFrame * CFrame.Angles(math.rad(MoveVector.X), math.rad(MoveVector.Y), math.rad(MoveVector.Z))

end)
Gif of the problem

https://gyazo.com/d4f057101236c238c39ef14ea886e97e

Thanks for reading, have an amazing rest of your day/night.

Yeah I believe the default CFrame is set at the origin of the world (0,0,0) with an orientation of (0,0,0) which is the players camera at the very moment of joining the game before they spawn.

I suggest using an invisible part CFrame that acts as the camera and using that as the default CFrame.

1 Like