FirstPerson script locks mouse

Aren’t you meant to parent it in player.PlayerGui?

my mistake, that was an accident lol

maybe this script works
btw this is the full script replace it

local UserInputService = game:GetService(“UserInputService”)
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer

– Lock the camera to first person
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) – Adjust the offset as needed

– Store the initial mouse position
local initialMousePosition = UserInputService:GetMouseLocation()

– Function to update camera rotation based on mouse movement
local function UpdateCameraRotation()
local currentMousePosition = UserInputService:GetMouseLocation()
local deltaMouse = currentMousePosition - initialMousePosition

local rotationY = deltaMouse.X / 100 -- Adjust the sensitivity as needed
local rotationX = deltaMouse.Y / 100

local currentRotation = camera.CFrame:ToEulerAnglesYXZ()
local newYRotation = currentRotation.Y + rotationY
local newXRotation = math.clamp(currentRotation.X - rotationX, -math.pi/2, math.pi/2)

camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(0, newYRotation, 0) * CFrame.Angles(newXRotation, 0, 0)
initialMousePosition = currentMousePosition

end

– Connect the function to the mouse movement event
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
UpdateCameraRotation()
end
end)

and it didnt get the full script

@Playfullgamer_YT @DiamondDrencher1 @remcodesremcodes
Thank you for all your help!!

np man i want to help as much people as i can

1 Like

to get the whole script, you have to wrap your text around three backquotes (`)

--[[
a```
code here
a```
]]

just uh, dont put the two a’s

ok ty i will do that next time

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.