Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Mouse lock for inventory system?

Im attempting to make a inventory system, when you click TAB the gui will be brought up and then i want your mouse to be able to move freely so you can mess with the inventory and things, and when you click TAB again the gui will be no longer visible then the mouse lock will be back.

Heres the script i have so far i just need the mouse part figured out.

local hotkey = Enum.KeyCode.Tab

local UIS = game:GetService("UserInputService") local open = false

UIS.InputBegan:Connect(function(key, gp) if key.KeyCode == hotkey then if UIS:GetFocusedTextBox() == nil then if script.Parent.Visible == true then script.Parent.Visible = false

			--Mouse unlock
			
		else
			script.Parent.Visible = true
			
			--Mouse lock
			
		end
	end
	end

end)

1 comment

0

Please reformat your code.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.