"attempt to index boolean with 'KeyCode' "

Hello again

So I was making a input system that changes a text label’s text every time you press it and this error keeps appearing: " Players.Nacidi.PlayerGui.ScreenGui.Frame.TextLabel.LocalScript:11: attempt to index boolean with ‘KeyCode’ "
my script here:

-- Services
local UserInputService = game:GetService("UserInputService")
-- Variables

local value = script.Parent:GetAttribute("ModeOn")
local debounce = false
local cd = 0.05
local text = script.Parent

	if value == false and input.KeyCode == Enum.KeyCode.Q  then
		debounce = true
		print("Mode On")
		text.Text = "Fighting Style Mode: On"
		value.Value = true
		debounce = false
	elseif value == true and input.KeyCode == Enum.KeyCode.Q then
		debounce = true
		print("Mode off")
		text.Text = "Fighting Style Mode: Off"
		value.Value = false
		debounce = false

How can I fix this?

Flip the parameters isTyping and input, the order matters a lot when it comes to inputObject and gameProcessedEvent.

1 Like

Input comes before isTyping, so it’d be function(input, isTyping)

1 Like