Custom Toggle Shiftlock function ignores all code which sets a value if the inputs keycode is Enum.KeyCode.DPadUp

I just spent the last 30 minutes trying to get my mobile & console shiftlock system working. It worked completely fine when pressing the GuiButton, but when trying to press DPadUp, literally every single line in the function which was setting something got completely ignored. Heres my code,

local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local enabled = plr.PlayerScripts:WaitForChild("Settings"):WaitForChild("Shiftlock")

local currentHumanoidOffset = Vector3.new(0, 0, 0)

wait()
if not plr.PlayerGui:FindFirstChild("TouchGui") and not game:GetService("GuiService"):IsTenFootInterface() then script.Parent.Parent:Destroy() return end
script.Parent.Parent.Enabled = true--not game:GetService("GuiService"):IsTenFootInterface()

function toggleShiftlock()
	if not enabled.Value then
		enabled.Value = true
		print(1)
		currentHumanoidOffset = Vector3.new(1.75, 0, 0)
		print(2)
		if plr.Character and plr.Character:FindFirstChild("Humanoid") then
			print(3)
			plr.Character.Humanoid.CameraOffset = currentHumanoidOffset
		end
		print(4)
	else
		enabled.Value = false
		print(5)
		currentHumanoidOffset = Vector3.new(0, 0, 0)
		print(6)
		if plr.Character and plr.Character:FindFirstChild("Humanoid") then
			plr.Character.Humanoid.CameraOffset = currentHumanoidOffset
			print(7)
		end
		print(8)
	end
	script.Parent.Image = enabled.Value and "rbxasset://textures/ui/mouseLock_on@2x.png" or "rbxasset://textures/ui/mouseLock_off@2x.png"
end

uis.InputBegan:Connect(function(input, gp)
	if gp then return end
	if input.KeyCode == Enum.KeyCode.DPadUp then
		toggleShiftlock()
	end
end)

script.Parent.MouseButton1Click:Connect(toggleShiftlock)

plr.CharacterAdded:Connect(function(char)
	local humanoid = char:WaitForChild("Humanoid")
	humanoid.CameraOffset = currentHumanoidOffset
end)

It makes absolutely no sense because EVERY SINGLE PRINT STATEMENT passed.
image

But after changing the keybind to Enum.KeyCode.DPadRight, it worked perfectly fine.
I also tested it with a bunch of other keycodes, and what do you know? EVERY single one worked.

Thanks for your report.
Without knowing how your ShiftLock Setting works, it’s hard to tell if this is correct or not.
Wouldn’t it be easier to use the built-in shiftlock option in player script ?

I made this setup for shiftlock so it will work for mobile and console players (Its completely inaccessible if you are on PC). I really don’t think the system had anything to do with the issue, especially considering changing the keybind for it resolves the issue.