Should I put a function in a table?

Heyo I have this code which is really bad so sorry I was just testing to see if I could do it so yeah

		local Sphere = workspace.Folder.Sphere:Clone() --this is used for the red background
		Sphere.Parent = workspace.Game.FX
		Sphere.Position = workspace.Game.Stage:GetChildren()[1].Camera.Position + Vector3.new(0,24.5,0)
		game.Lighting.Bloom.Intensity = 0 --> lower the bloom to remove the glow from the neon
		--> set every characters parts to black, but also save their current color so I can switch back to it later
		for _,Character in pairs(workspace.Game.Characters:GetDescendants()) do
			for _,Part in pairs(Character:GetDescendants()) do
				if Part:IsA("Part") or Part:IsA("UnionOperation") or Part:IsA("MeshPart") or Part:IsA("BasePart") then
					if Character == Main.Character then
						PreviousColorP1[Part.Name] = Part.BrickColor
					else
						PreviousColorP2[Part.Name] = Part.BrickColor
					end
					Part.BrickColor = BrickColor.new("Really black")
					Part.Material = Enum.Material.Neon
				end			
			end
		end
		Modules.Camera.Zoffset = 7 --> zoom the camera in
		--> after 3 seconds set everything back to nromal
		coroutine.wrap(function()
			wait(3)
			Sphere:Destroy()
			game.Lighting.Bloom.Intensity = 0
			Modules.Camera.Zoffset = 12
			for _,Character in pairs(workspace.Game.Characters:GetDescendants()) do
				for _,Part in pairs(Character:GetDescendants()) do
					if Part:IsA("Part") or Part:IsA("UnionOperation") or Part:IsA("MeshPart") or Part:IsA("BasePart") then
						if Character == Main.Character then
							Part.BrickColor = PreviousColorP1[Part.Name]
						else
							Part.BrickColor = PreviousColorP2[Part.Name]
						end
						Part.Material = Enum.Material.Plastic
					end			
				end
			end			
		end)()

All of this code does this


So now what I wanted to know is what if I wanted a specific move to do all of this? I was thinking about putting a function inside a dictionary of the move and then in my combat script I can check if the move has any functions that need to be ran, but this is probably dumb lol. So need some help with this because I’m not sure what to do.

Also here’s what the dictionary for one of my moves look like and where I would put the function.

    [23] = {
        MovePriority = 1;
        MoveType      = "Air";
        Name          = "Air Hard Kick";
        Sequence      = {"HK"};
        Animation    = "rbxassetid://7158971925";
        Damage = 80;
        Stun = 40;
        HitboxData = {
            ProxBlockAreaSize = Vector3.new(1.8,1.6,8);
            Orientation = {30,90,0};
            ProxBlockAreaPos = {3,0};
            HitboxSize = Vector3.new(1.8, 1.6, 3);
            HitboxPos = {3,0};            
        }
    };    
local Table = {
	[1] = function()
		print("hi")
	end,
	[2] = "Ok",
	[3] = {
		["name"] = "bob"
	}
}

Table[1]()

This works. Tested in studio. Just do something like that.

You could do like
functionToDoStuff = function()

end)

1 Like