How can i do this with tables?

I made a table with a list of values tied to specific names, and i want to make a local variable or something that will be able to read a string value inside the player then according to the string value’s value in the player, thats the value thats chosen like for example
Screenshot 2024-12-07 191213


I made a table with these values, and the currentcart value is the string value inside the player and when the script reads it according to its value, its chosen in the table

I made a script where when a player presses a button, an accessory vehicle spawns on them and the speed increases to seem like they are riding that vehicle
I want the vehicles to be all different speeds and not a fixed one which is why i want to make something like this, depending on the vehicle they choose (the currentcart stringvalue) they will go at differnt speeds, my attempt was the third picture but it didnt seem to work, can anyone help? (i might not be explaining well enough so please tell me if i need a better explanation)

You can index the dictionary with the value of the string

local speed = BaseSpeeds[CurrentCart.Value]

wow, i thought it would require more code i didn’t know it’d be this simple thanks for the help!

1 Like

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