String expected, got table

Making a relatively simple keybind system but I get this error when accessing data from the keybind, heres how im doing it

if input.UserInputType == Enum.UserInputType[KeybindSettings.currentKeybinds][tool.Name][script.Name] or input.KeyCode == Enum.KeyCode[KeybindSettings.currentKeybinds][tool.Name][script.Name] then
		print("Worked")
	end

invalid argument #2 (string expected, got table)

Here is the moduleScript im accessing it from

currentKeybinds = {
		["Pass"] = {
			["Pass"] = "MouseButton1" -- The one im trying to make work right now.
		},
		["Kick Types"] = {
			["Backspin"] = "Q"
		}
	}
1 Like

why dont you make [“Pass”] equal to Enum.UserInputType.MouseButton1

2 Likes

I have to save these keybinds, but Datastores will not accept enums, thats what I thought of too

oh youre right my bad

… … …

2 Likes

Okay, I figured out that it has to do with the way I indexxed it, it’s just weird but I just turned it into a variable like this

local keybind = KeybindSettings.currentKeybinds[tool.Name][script.Name]
	if input.UserInputType == Enum.UserInputType[keybind] or input.KeyCode == Enum.KeyCode[keybind] then
		print("Work")
	end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.