LayoutOrder not working on UIGridLayout? [SOLVED, DICTIONARY ISSUE]

i am trying to create a moveset in order with the table i have:

local input_moves = {
	["M1"] = Enum.UserInputType.MouseButton1,
	["Uppercut"] = Enum.KeyCode.Q,
	["Kick"] = Enum.KeyCode.E,
	["Heavy Punch"] = Enum.KeyCode.R,
	["Knife Throw"] = Enum.KeyCode.T,
	["Elbow Charge"] = Enum.KeyCode.F,
	["Awakening"] = Enum.KeyCode.H,
	["Pose"] = Enum.KeyCode.P,
}

and i have this loop to add it to the ui:

local order = 0
for name, key in input_moves do
	order += 1
	rep.MovesetVisual:Fire(name, key.Name, order) -- name, key, order
end

here is the code for cloning the template:

rep.MovesetVisual.Event:Connect(function(name, key, order)
	if name == "M1" then
		name = "Punch Combo"
		key = "M1"
	end
	
	local move = template:Clone()
	move.AbilityName.Text = name
	move.Key.Text = key
	move.Parent = ui
	move.LayoutOrder = order
end)

what ends up happening when playing is this, however:
image
seemingly random frames in no particular order.

any help would be great, thanks.

I think what you would need to do, is set the name of move to order, then for whatever layout type you are using, set the sort order property to name, this should fix the issue in theory.
I would also recommend using a UIListLayout instead of a grid, but honestly it doesnt matter to much as its going to give about the same results

1 Like

nope, nothing changed.

local move = template:Clone()
move.Name = order
move.AbilityName.Text = name
move.Key.Text = key
move.Parent = ui

really weird honestly xd
thanks for the help regardless :stuck_out_tongue:

local input_moves = {
	Enum.UserInputType.MouseButton1,
	Enum.KeyCode.Q,
	Enum.KeyCode.E,
	Enum.KeyCode.R,
	Enum.KeyCode.T,
	Enum.KeyCode.F,
	Enum.KeyCode.H,
	Enum.KeyCode.P,
}

Dictionaries are hard to index through so like @FroDev1002 said, try using an array like the above.

1 Like

but you see i want a dictionary since it controls which remotes to fire and which abilities to activate, is there any way to avoid this?

just realised; it’s because dictionaries loop things in ALPHABETICAL ORDER! i need to do this:

{
	[1] = {
		Name = "hi"
	}
}

i feel so silly xD. sorry for wasting your time!

1 Like

Can I see the properties of the UIGridLayout?
Oh yes!!

When looping through the dictionary, chances are it doesnt sort in order, so if you turn it into an array, it should sort correctly. Since you want this:

You can just do this:

local input_moves = {
    {Input = Enum.UserInputType.MouseButton1, Name = 'M1'}
}

Oh you figured it out lol

1 Like
local input_moves = {
	["M1"] = 1,
	["Uppercut"] = 2,
	["Kick"] = 3,
	["Heavy Punch"] = 4, -- You see where I'm going with this
	["Knife Throw"] = Enum.KeyCode.T,
	["Elbow Charge"] = Enum.KeyCode.F,
	["Awakening"] = Enum.KeyCode.H,
	["Pose"] = 
}

local input_moves = {
	Enum.UserInputType.MouseButton1,
	Enum.KeyCode.Q,
	Enum.KeyCode.E,
	Enum.KeyCode.R,
	Enum.KeyCode.T,
	Enum.KeyCode.F,
	Enum.KeyCode.H,
	Enum.KeyCode.P,
}

or map the 2 tables together

1 Like

@effbeecee

haha, thank you both for the solutions. i will be noting of this in the future to avoid any more silly things happening with dictionaries :))))))))
I HATE DICTIONARIES

2 Likes

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