Lets say I want a model to be called "Car One" based on a value (1) so if the value is 4, the model will be called "Car Four". I'm wondering if there's a shortcut to turn number values to words.
✓ ANSWER ACCEPTED
Is there an easy way to do this?
1 answer
✓ Accepted answer
You can easily do this by concatenation. But first, you need to make a Dictionary. Dictionaries are essentially tables with keys and values.
So, lets make a dictionary with keys of the full word, and values of the number. Then according to the number value, iterate through the table. If there's a match then concatenate the key with the model name.
local nums = {
['One'] = 1,
['Two'] = 2,
['Three'] = 3,
['Four'] = 4
}
local numVal = workspace.NumberValue --Just an example
local model = workspace.Car
for i,v in pairs(nums) do
if v == numVal.Value then
model.Name = model.Name..i
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
thanks
Doesn't it make more sense to go the other way? words = { "One", "Two", "Three", "Four" } ??
Yeah, you can do that then just index it like nums[i]. But I thought this might be more understandable, as well as it teaches them about Dictionaries(: