How would I get the dropbox for “IdleAnimation” and “SwingAnimation” to appear after “Animations.”, I would like for it to show it like in the next image.
I already defined the type for Animations under NPC as [string]:AnimationTrack, I would like for the keys in the table to show up directly though. Is this possible? Should I use function generics for this? The code I am using is under. (I cutted some code that isn’t important for the context out).
export type NpcObject = {
Character:Model,
Humanoid:Humanoid,
HumanoidRootPart:BasePart,
Animations:{
[string]:AnimationTrack
}
}
local Methods:NpcObject = {}
local Constructor = {}
export type ConstructorValues = {
Character:Model,
AnimationTable:{
[string]:string -- the key would be the name of the animation, the value would be the animation id
-- ex ["ExampleAnimation"]:rbxassetid:1234567890
}?,
}
function Constructor.newNPC(ConstructorValues:ConstructorValues):NpcObject
local NewNpc = table.clone(Methods)
NewNpc.Character = ConstructorValues.Character
NewNpc.Humanoid = ConstructorValues.Character.Humanoid
NewNpc.HumanoidRootPart = ConstructorValues.Character.HumanoidRootPart
NewNpc.Animations = {}
for AnimationName,AnimationId in pairs(ConstructorValues.AnimationTable) do
local Animator:Animator = NewNpc.Humanoid:FindFirstChild("Animator") or Instance.new("Animator")
local Animation = Instance.new("Animation")
if not Animator.Parent then Animator.Parent = NewNpc.Humanoid end
Animation.AnimationId = AnimationId
NewNpc.Animations[AnimationName] = Animator:LoadAnimation(Animation)::AnimationTrack
end
return NewNpc
end
return Constructor