Map voting UI displaying weirdly?

My map voting UI text is displaying wrong and here are two scripts I might need to show. The script picks some maps stores it in a table then sends it to the client to display on-screen. Not too sure how to fix:

Code 1

Client script which organizes how the map buttons display (button handling in the for loop). The text is set to a folder (with a name like: Red_Map) which has the map inside of it and it is replacing the _ with a space. But I’m not to sure why its displaying wrong text:
code 2

What do you mean by “displaying wrong”? What do you expect it to look like, and what does it currently look like?

Screenshots are recommended.

Hi thanks for the reply so sorry i was late.

This is what the map voting displays like:
The names of the map are displaying incorrectly but I have checked the imageid attributes associated with each map and they seem to be in the right order just when the client script is displaying it, it is showing wrong.

Not exactly the kind of screenshot I was expecting (e.g. using Snip & Sketch/Snipping Tool to capture what you are actually seeing on studio.)

The phrases “displaying incorrectly” and “showing wrong” are quite vague and can mean anything related to GUI problems. Be descriptive.

Based on what I’ve read, are you not seeing the names of maps in alphabetical order?

Edit: I don’t know if this is what you are looking for, but after randomizing your map roster, use table.sort(Maps). This function does not return anything, but it sorts the table you give to it.

Arrays never auto-sort their values unless you sort them yourself or with the table.sort() function. This is intentional to keep the order of items in an array from the first to the last item inserted (e.g. {1, 5, 4, 2} stays as {1, 5, 4, 2} instead of {1, 2, 4, 5}).

1 Like

Thanks for reply.

Yes so my map names aren’t with the correct map images. They are just muddled up.

This definetely seems like the fix. So instead of table.insert() in the mainscript I should do table.sort(Maps) or do I do it after table.insert()? I am a bit confused I got this off a yt video

After the script finishes the map roster (after the number of Maps reach 3), run table.sort(Maps).

You use table.insert() when you want to add a new item in a table, while table.sort() sorts a table.

1 Like

You are right when I use table.sort(Maps) it sorts the maps in the right spot I printed it out in the output just to make sure it works but the text still isn’t in order with the maps.

I have blue map on-screen but beneath it it’s saying red map etc. Is there a way I could fix this too? Where it says MapButton.Text in the client script I tried adding a table.sort to it and remembered that it’s not a table. How can I order this in right spot?

What could MapNameTextLabel be? Is this the element that shows the name of the map? If yes, then if its parent is MapButton, try MapButton.MapNameTextLabel.Text.

Yes. I have made a variable called MapNameTextLabel which is parented to the MalButton and it’s what displays the map name. If you are wondering I had a folder for each map in replicated storage and that’s why it says: MapNameTextLabel.Text = string.gsub(Value, “_”, “ “) . The folders all have names like: Blue_Map, Pink_Map etc. And this converts it to: Boue Map, Pink Map, etc. But for some reason it is showing the map names but in the wrong spots.

The MapNameTextLabel isn’t accessed from the MapButton, which could probably mean you’re editing a different “MapNameTextLabel”.

Have you tried what I suggested?

Thank you so much learning something new everyday. Especially with tables they are like a never ending learnable thing lol.

1 Like

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