F to unlock mouse script not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am making an F to unlock mouse script.

  2. What is the issue? Include screenshots / videos if possible!
    Even if I press F, my mouse is still locked at the middle of the screen.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The script is in starter GUI and also as a LocalScript.

local uis = game:GetService("UserInputService")


uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F then
		if script.Parent.MouseUnlock.ImageButton.Visible == false then
			script.Parent.MouseUnlock.ImageButton.Visible = true
		else
			script.Parent.MouseUnlock.ImageButton.Visible = false
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

I remember solving this some time ago. What you have to do is make the .Modal BoolValue turn to true. This will unlock the mouse. Setting it to false will lock the cursor again.


For more context;

3 Likes

I have set Modal to true.

30CHARBYPASS

1 Like

The texbutton’s Visible property has to be true at all times and that the TextButton takes up the entire screen. If that does not fix your issue, the topic I linked has the exact setup and code for it to work.

1 Like

my bad i just misunderstood your reply

2 Likes

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