Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Locking Players Camera In Mouse Lock Angle?

Asked by
StoIid 364 Moderation Voter
8 years ago

I need help figuring out how I can lock a players camera in the mouse lock angle. I made a script that makes you face where your mouse is pointing

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

game:GetService("RunService").RenderStepped:connect(function()
    if humanoid.Health > 0 then
        character.Torso.CFrame = CFrame.new(character.Torso.Position, Vector3.new(mouse.Hit.p.X, character.Torso.Position.Y, mouse.Hit.p.Z))
    end
end)

Any help finding out how to make the camera angle stay in the mouse lock angle position?

1 answer

Log in to vote
0
Answered by
Unlimitus 120
8 years ago

I actually answered a question very similar to this a few days ago. You don't need to write a custom camera. Do what I say below to get a MouseLock Camera:

First: Play Solo, go to the Player object, and copy the CameraScript in PlayerScripts.

Second: Paste that script in StarterPlayerScripts. DO NOT rename it. There is a line in that script that
removes the the original script and replaces it with this one.

Third: Open up the "RootCamera" Module. Change line 112 to this.ShiftLock = true.

Fourth (or Third pt. 2) Change line 126 to return true

Hope this helps!

0
How would I make it possible for the player to move their mouse if needed? StoIid 364 — 8y
Ad

Answer this question