-
What do you want to achieve?
I want to use an enum-like table as the keys for a custom Luau type. -
What is the issue?
I have no idea how to do it. All I’ve tried doesn’t work. -
What solutions have you tried so far?
I’ve looked around the interwebs for some information about this. But I haven’t found anything related to my problem.
I have also tried using the syntax:
[key1]: number, [key2]: number, ...
and so on, but it doesn’t work ('cause they’re table indexing syntax).
Here’s my code and the implementation I tried before:
Enum (ModuleScript)
--[[
Name definitions for each body part in custom character
]]
local CustomBodyPart = {
LEFT_ARM = "Left Arm",
RIGHT_ARM = "Right Arm",
LEFT_LEG = "Left Leg",
RIGHT_LEG = "Right Leg",
HEAD = "Head",
TORSO = "Torso",
}
table.freeze(BodyPart)
return CustomBodyPart
Custom Type (ModuleScript)
--[[
Type defining the colours for custom body color
]]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CustomBodyPart = require(ReplicatedStorage:WaitForChild("component").module.CustomBodyPart)
export type CustomBodyColorAppearance = {
[CustomBodyPart.LEFT_ARM]: Color3,
[CustomBodyPart.RIGHT_ARM]: Color3,
[CustomBodyPart.LEFT_LEG]: Color3,
[CustomBodyPart.RIGHT_LEG]: Color3,
[CustomBodyPart.TORSO]: Color3,
[CustomBodyPart.HEAD]: Color3,
}
--^ error: 'cannot have more than one table indexer'
return nil
Any idea on how to do this? All help is appreciated.