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?

1 comment
dang i was way off everyone i went to said to code it like that, im never asking them for help with code again thats for sure