Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a FNAF camera so its not really buggy?

I am trying to make a fnaf like game, i am having trouble with the camera movement system, It's really buggy and just moves everywhere, how do i fix this? Example: https://gyazo.com/71b694f55a2244b5922baa9a3c8e1830 What i want it to be like: https://gyazo.com/44368d69dada53f60f0745f44fbeb1f6

local Player = game:GetService("Players").LocalPlayer
local Cursor = Player:GetMouse()
local Camera = workspace.CurrentCamera
wait(1)
local part = Player.Character.Head

repeat wait(1) until Player.Character.Parent == workspace

Camera.CameraSubject = Cursor
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = part.CFrame

Cursor.Move:Connect(function()
    wait(0.1)
    Camera.CFrame = CFrame.new(part.Position, Cursor.Hit.p)
end)

1 answer

Have you tried using game:GetService('UserInputService').MouseBehavior = Enum.MouseBehavior.LockCenter?

local Player = game:GetService("Players").LocalPlayer
local Cursor = Player:GetMouse()
local Camera = workspace.CurrentCamera
wait(1)
local part = Player.Character.Head

repeat wait(1) until Player.Character.Parent == workspace

Camera.CameraSubject = Cursor
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = part.CFrame
game:GetService('UserInputService').MouseBehavior = Enum.MouseBehavior.LockCenter

Cursor.Move:Connect(function()
    wait(0.1)
    Camera.CFrame = CFrame.new(part.Position, Cursor.Hit.p)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.