Make Cursor moveable while in First Person

I have a game where the players camera is locked in first person. How do I make the cursor moveable
while the player remains in first person? This is the script I have and for some reason it doesn’t work:

ChatPrompt - LocalScript - StarterCharacterScripts:

local UserInputService = game:GetService('UserInputService')

local Player = game.Players.LocalPlayer
local Character = Player.Character
local HumanoidRootPart = Character:FindFirstChild('HumanoidRootPart')

local PlayerGui = Player.PlayerGui
local ChatGui = PlayerGui.ChatGui
local Prompt = ChatGui.Prompt

local LocalMessageEvent = game.ReplicatedStorage.Remotes.Chat:WaitForChild('DisplayLocalMessage')
local GlobalMessageEvent = game.ReplicatedStorage.Remotes.Chat:WaitForChild('DisplayGlobalMessage')

local ChatOpened = false
local GameSettings = game.ReplicatedStorage.Remotes.ReturnGameSettings:InvokeServer()

local Controls = require(Player:WaitForChild('PlayerScripts'):WaitForChild('PlayerModule')):GetControls()

UserInputService.InputBegan:Connect(function(Key)
	
	if Key.KeyCode == GameSettings.Controls.Chat then
		
		if ChatOpened then

			Controls:Enable()
			
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
			
			Prompt.Visible = false
			Prompt.TextBox.Text = ''
			ChatOpened = false
			UserInputService.MouseIconEnabled = false
			
		else
			
			Controls:Disable()
			
			UserInputService.MouseBehavior = Enum.MouseBehavior.Default
			Player.CameraMode = Enum.CameraMode.Classic
			
			Prompt.Visible = true
			Prompt.TextBox.Text = ''
			ChatOpened = true
			UserInputService.MouseIconEnabled = true
			
		end

	elseif Key.KeyCode == Enum.KeyCode.Return and ChatOpened then
		
		local Message = GameSettings.Chat.Message
		
		string.gsub(Message, "{DisplayName}", Player.DisplayName)
		string.gsub(Message, "{Username}", Player.Name)
		string.gsub(Message, "{UserId}", Player.UserId)
		string.gsub(Message, "{Message}", ChatGui.Prompt.TextBox.Text)
		
		game.ReplicatedStorage.Remotes.Chat.DisplayLocalMessage:Fire(Message, GameSettings.Chat.DefaultChatColor)
		Prompt.TextBox.Text = ''
	end
end)

I tried unlocking the cursor but it doesn’t work. Maybe because of the ‘LockFirstPerson’ property in StarterPlayer? Does anybody have an idea on how to solve this? Thanks!

1 Like

I solved it. I had to set the cameramode to scriptable.

1 Like

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