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!

2 comments
ok
I'm not sure v has this problem, but certain Enum.KeyCode values will return true for isTyping, because it's really gameProcessedEvent, and it might mean typing, mouseLock, leaderboard, backpack, etc. processed it