does anyone know how to make for the camera to rotate player isnt required to hold the right mouse click but it will always by itself follow the mouse without needing to hold the right mouse button
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
-- Variable to track if the mouse is locked or unlocked
local mouseLocked = true
-- Function to lock the mouse
local function lockMouse()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
mouseLocked = true
end
-- Function to unlock the mouse
local function unlockMouse()
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = true
mouseLocked = false
end
-- Initial lock
lockMouse()
-- Listen for the Tab key press to toggle mouse lock/unlock
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab then
if mouseLocked then
unlockMouse()
else
lockMouse()
end
end
end)
Well just in case you wanted to know, Roblox comes with a built-in lock that moves the camera via the player’s mouse movement. (whilst keeping the mouse at the center of the screen ofc)
Activating it is super easy, by pressing pause in Roblox and going to settings, there should be an option to toggle on and off shift-lock. Once enabled, press L-Shift on your keyboard to turn it on and off.
I believe you can edit shift-lock controls and make the button Alt instead of L-Shift (in case you have a stamina system.)
Since you’re using HeCatchThose’s answer I would recommend disabling the shift lock in studio, just in case it interferes with the code.