How would I make a fnaf style camera?

What I’m trying to do is make a camera part rotate towards the mouse. So far I have this:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

while wait() do
	workspace.CameraPart.Orientation = Vector3.new(0, mouse.X, 0)
end

Nothing I’ve tried works, anyone got any solutions?

1 Like

Try printing what Mouse.X is giving?

Also why are you setting the y value with the X axis of the mouse?

When I rotate the part from side to side, it changes the Y value. It prints out 0 to 1080.

That’s odd, I tried it out myself and it was working for me.

Maybe try this?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = workspace.CameraPart

mouse.Move:Connect(function()
	part.Orientation = Vector3.new(0,mouse.X,0)
end)
1 Like

Hm, doesn’t work. Weird. Im confused here.

3 Likes

Okay I’m confused, it worked for me but not for you? Could you show me a video so I can see what may be the issue

2 Likes
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local camPart = nil -- Your cam part

local rotateAmount = 5

local function enable()    
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = camPart.CFrame
    game:GetService("RunService"):BindToRenderStep("CameraLookAtMouse", Enum.RenderPriority.Camera.Value + 1, function()
        camera.CFrame = camPart.CFrame * CFrame.Angles(
            math.rad((mouse.Y - mouse.ViewSizeY) / mouse.ViewSizeY * -rotateAmount),
            math.rad((mouse.X - mouse.ViewSizeX) / mouse.ViewSizeX * -rotateAmount),
            math.rad(0)
        )
    end)
end

local function disable()
    game:GetService("RunService"):UnbindFromRenderStep("CameraLookAtMouse")
    camera.CameraType = Enum.CameraType.Custom
end

enable()
3 Likes