So my friend made me a simple first person lock script for my game, this is the script: wait(.1) game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.Classic game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
I've tried a couple ways to make it if they hold down say the button "g" it would free there mouse, But I can't get it to work. Anyone know a way how?
The answer lies in UserInputService
You could either have a loop continually checking ":IsKeyDown(Enum.KeyCode.G)", or better would be to listen to the "InputBegan" and "InputEnded" events:
wait(0.1) game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson s = game:GetService("UserInputService") s.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.G then game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic end end) s.InputEnded:connect(function(input) if input.KeyCode == Enum.KeyCode.G then game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson end end)