So im making a FPS game right now and you should be able to switch teams. The problem is its locked in first person and i need you need to unlock the Mouse in order to press the "Change Team" Button. I thought about making it modal it works but it doesn't really work mit my fps since you need to hold right click to look around in first person and i dont want that. I want to lets say Press M to unlock the Mouse and then press M again to lock it
Im pretty new to scripting so i made this:
local uis = game:GetService("UserInputService") local rs = game:GetService("RunService") local debounce = false wait(1) game:GetService("UserInputService").InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.M and debounce == false then debounce = true uis.MouseBehavior = Enum.MouseBehavior.LockCenter elseif input.KeyCode == Enum.KeyCode.M and debounce == true then debounce = false uis.MouseBehavior = Enum.MouseBehavior.Default end end)
But that doesnt work and i dont know why
If the error ServerScriptService.DefaultFPS.FPSMain:17: workspace.Script - attempt to index nil with - then dont worry it's happening to everyone. It does not do anything