So lets suppose i have a meta table
1 | local tablevalues = { "A" , "B" , "C" } |
2 | local value = nil |
so i wanted to know how could i switch these values in order for example when a keyboard key is pressed, i want to change value to one of these tablevalues value correctly in order, can someone help me? i am stil llearning meta tables...
Modify your script to this:
01 | local tablevalues = { "A" , "B" , "C" } |
02 | local NextTable = 1 |
03 |
04 | game.Players.LocalPlayer:GetMouse().Button 1 Down:Connect( function () |
05 | print (tablevalues [ NextTable ] ) --printing the next data val |
06 | if NextTable = = #tablevalues then --Checking if this is the last value of the table and we need to go back to pringing number 1 |
07 | NextTable = 1 --Saying we need to go back to printing #1 |
08 | else |
09 | NextTable = NextTable+ 1 --If its not the last value, advance to the next value. |
10 | end |
11 | end ) |
This will work with as many values as you put in that table. You can keep adding if you desire. With further questions/comments/concerns, feel free to reply to my answer. Happy scripting! ~mc3334