New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How would i do this specific Shift lock?

Asked by 14 days ago
Edited 14 days ago

For my game, I'm trying to force a shift lock that controls the camera but also only makes the character look at the camera center when right-click is down. How would I do this? I have tried this but this just puts the cursor at the center and makes the Character face 1 particular direction

local players = game.Players.LocalPlayer
local Mouse = players:GetMouse()
local UserInputService = game:GetService("UserInputService")
local Character = players.Character or players.CharacterAdded:Wait()

wait(2)

Mouse.Button2Down:Connect(function()
Character.Humanoid.AutoRotate = false
while Mouse.Button2Down ==true do
Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.CFrame,game.Workspace.CurrentCamera.Focus)
end
end)


Mouse.Button2Up:Connect(function()
Character.Humanoid.AutoRotate = true
end)


Character.Humanoid.AutoRotate = false
while true do game:GetService("RunService").Heartbeat:Wait()
    UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end






A good example of a game that does this is Warframe. The character only looks at the camera focus when aiming

0
:I Oblivious_Blitz 1 — 14d

Answer this question