Attempt to index string with EnumItem

I’m making a keybinds module that will store the keybinds for each “action” and I am making a function that converts the enums to a string, for example:

Enum.UserInputType.MouseButton1 becomes a string "UserInputType/MouseButton1"

I am currently having trouble doing this, and It is giving me this error

string.format("%s/%s", tostr:12: attempt to index string with EnumItem

local Keybinds = {
	current = {
		["Dribble"] = {
			["Dribble"] = Enum.UserInputType.MouseButton1
		}
	}
}

function Keybinds:convertToString()
	for _, tool in Keybinds.current do
		for key, enum in tool do
			key[enum] = string.format("%s/%s", tostring(enum.EnumType), tostring(enum.Name))
		end
	end 
end

(For anyone wondering, I am doing this so I can save it to a datastore, datastores do NOT save enums)

What are you even expecting key[enum] to do? key, from what I could make out, is just “Dribble” and enum is just an enum, so you’re doing "Dribble"[Enum.UserInputType.MouseButton1] = ...

1 Like

Yea I made it tool[key] and it worked

Thank you my glorious blockyhead goat M17 hannes213 (Programmer)

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