my game is based out of first person and im trying to enable mouse movement in first person when the key m is pressed and after key m is pressed again the mouse will stop movement and beome disabled heres my code
local UserInputService = game:GetService("UserInputService") while true do UserInputService.MouseIconEnabled = false function onKeyPress(actionName, UserInputState, input0bject) if UserInputState == Enum.UserInputState.Begin then UserInputService.MouseIconEnabled = true UserInputService.ModalEnabled = true end end end game.ContextActionService:BindAction("KeyPress", OnKeyPress, false, Enum.KeyCode.M)
UPDATE: the code is working now but i still cannot enable the movement of my mouse however i now have it when the mouse icon is enable it does not disable it self when clicked or it will not appear when m is pressed?
local UserInputService = game:GetService("UserInputService") UserInputService.MouseIconEnabled = false UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.M then UserInputService.MouseIconEnabled = true --if UserInputService.MouseIconEnabled == true then --UserInputService.MouseIconEnabled = false end end end)
there is nothing in the output currently?
im just gonna be honest what ever you were doing wasnt gonna ever work ill just give you the code now(local Script)
game:GetService("UserInputService").InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.M then -- Let mouse move idk how to do that end end)