local function enumToStr(enum)
local str = tostring(enum.EnumType).."/"..enum.Name
return str
end
local function strToEnum(str)
local path = string.split(str,"/")
local enum = Enum
for _,v in path do
enum = enum[v]
end
return enum
end
Im pretty sure the enum tree structure only has a depth of 3 so this should work.
If you want to stick with user input service, i’m afraid there isnt. Most of this complexity is induced because you want to save the binds VIA datastore and the binds are not just key or mouse. Overall, this solution is actually not too complicated. Here is a breakdown
When a player joins fetch all of their data from the datastore (in string format). Put it through the unwrapper I provided and store all of this data as Enum Items in runtime. (This will be more efficient as this table will be constantly read and compared with other enum items. If we stored as a string, we would be calling this unwrapper function every time we needed to check a bind). Now that we have binds stored as enum items, we can use the code i provided as a response to the OP which checks if we are dealing with UserInputType or KeyCode. On playerRemoving, take the binds we have and put them through the wrapper converting each enum item into a string. (That string is really just a path to said enum item). Save each string to the datastore for use the next time the player joins.
If theres any part of that you want more clarification on lmk.
That table is the table that would come from the datastore. A player joins, just do:
local runtimeBinds = {}
for i,v in keybinds do
runtimeBinds[i]={}
for i2,v2 in v do
runtimeBinds[i][i2] = unwrapperFunction(v2)
end
end
Use that code when a player joins, runtime binds is then the binds in enum format which can be used by ur scripts. When a player leaves, run the same code, except with the wrapper function I provided above. Then push that table to datastore.