How can I improve this?

For some reason I keep getting these orange things on the scroll bar but my script works and doesn’t error out, what can I do to fix this?


It’s because I am doing [_].


1 Like

Instead try:

for i, AvailableCommands in pairs(Detail) do 

And replace _ with i when you use _? Thats what I like to do… Might not be ideal though for you and may or may not work. I’m just guessing the roblox syntax doesn’t like _ and may like a character (a-z, A-Z) better?


Thanks for the help, I thought of changing it to for AvailableCommands in pairs(Detail) do and replaced _ with AvailableCommands see if that would work, and it did!

1 Like

Well so:

for i, AvailableCommands in pairs(Detail) do 

In this example:

  • i means the Number it Indexed in the table.

  • Where AvailableCommands is the Value of said indexed. In other words:

Detail[i] = AvailableCommands

So… To save you some words you could really do:

Template.LayoutOrder = AvailableCommands.LayoutOrder
--etc. etc.

I would just recommend this as it’s better and easier to read. :slight_smile: But both methods do work as needed, and really up to developer preference.

Example of this:

local ExampleTable = {
[1] = "This is Value One",
[2] = "And this is Value 2!",
[3] = "Value 3 here!", }

for Indexed, Value in ExampleTable do 
     print(Indexed, Value) 
     print(Indexed, ExampleTable[Indexed] ) 

--Following is printed: 

--1 This is Value One
--1 This is Value One
--2 And this is Value 2!
--2 And this is Value 2!
--3 Value 3 here!
--3 Value 3 here!
1 Like

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