How do I fix mouse unlock script?

I am currently trying to make a script to unlock the player’s mouse when they press T. If I try to make more UI elements to show the mouse is unlocked, the mouse doesn’t unlock. Here is my current script:

local UserInputService = game:GetService("UserInputService")

local UI = script.Parent.Parent
local Value = 0

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.T then
		if Value == 0 then
			UI.Enabled = true
			Value = 1
		else
			if Value == 1 then
				UI.Enabled = false
				Value = 0
			end
		end
	end
end)

If a video is needed I can post one.

1 Like

Can you provide a video? I don’t get what this script has to do with unlocking the mouse

i’m assuming you’re using a modal ui element to unlock the mouse, can you post the explorer and show which one it is if so?

Oh, I found out I just had to enable modal on the UI. Although is there a way I can use studio without it preventing me from selecting parts from clicking on them?

do you mean using the select tool?


its right here in studio, click it and it lets you select things by clicking on them

1 Like