Hey. I made a script that whenever a player presses V it will change his CameraMode. For some reason it won't work, and it won't return any error to the output. Here's my script, lines 29-40:
local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(isTyping, KeyCode) if not isTyping then if KeyCode.KeyCode == Enum.KeyCode.LeftShift then local players = game:GetService("Players") local localPlayer = players.LocalPlayer local character = localPlayer.Character local humanoid = character.Humanoid local speed = 19 humanoid.WalkSpeed = tonumber(speed) end end end) UIS.InputEnded:connect(function(isTyping, KeyCode) if not isTyping then if KeyCode.KeyCode == Enum.KeyCode.LeftShift then local players = game:GetService("Players") local localPlayer = players.LocalPlayer local character = localPlayer.Character local humanoid = character.Humanoid local speed = 13 humanoid.WalkSpeed = tonumber(speed) end end end) UIS.InputBegan:connect(function(isTyping, KeyCode) if not isTyping then if KeyCode.KeyCode == Enum.KeyCode.V then local localPlayer = game.Players.LocalPlayer if localPlayer.CameraMode == Enum.CameraMode.Classic then localPlayer.CameraMode = Enum.CameraMode.LockFirstPerson elseif localPlayer.CameraMode == Enum.CameraMode.LockFirstPerson then localPlayer.CameraMode = Enum.CameraMode.Classic end end end end)
I will make sure to accept the helpful answer!
It's because you have (isTyping, KeyCode)
. Please note that the order of the parameters do actually matter. The first parameter of this event is the Input and the next is gameProcessedEvent. So in your script, 'isTyping' is being assigned to the Input, and 'KeyCode' is being assigned to gameProcessedEvent. Just switch the parameters around and it should work.