No, im not trying to modify the dictionary item. I’m trying to set the name or index of a variable to that dictionary items value, so essentially it should be the equivalent of saying:
Is there a reason why you can’t use a dictionary? I tested it and if you make a second dictionary with the key being the value “Hi” from the first dictionary, you can use it like you would a variable just with the dictionary.
yes, because im making a system where the variable needs to have a specific name given to it by a client and it can only be a variable not a dictionary, as the name of the variable that contains a dictionary is important because it is addressed later on in the script.
I am saying that I want to use a predefined name to give that variable a name, like so:
local Kitten = "String"
local Kitten = 4
print(Kitten) --> 4, Variable name kitten.
However that isn’t how variables work and is confusing so what I used the dictionary for was to say:
local Table = {
["Kitten"] = "Name"
}
local Table["Kitten"] = "Kyle"
so what I did here was take the value of Kitten in the table and set the name of the variable below to its value aka Name, and gave it a different value
so if this were to work, when I print:
print(Name) --> Kyle
However roblox wont allow me to do this so I am looking for an alternative or some way to do it.
hopefully that was able to help you understand what I’m asking.
If you want to rename the key in a dictionary, you’re going to have to assign the old key to nil and then create a new key by the name you want it to be and set the value.
If this doesn’t work, it’s possible that it may be using a reference (i.e. local t = table; local i = t; t = nil; i == nil -> true so you can probably do dict["Key1"].."" and it should make a new reference, though I may be wrong on that.
no, i’m not sure how to explain this. I want to rename a variable to another variables name.
if I have a variable called:
local cat = 5
I want to change it so that the name of the variable (cat) is something like dog. so it still has the same value I just changed the name. this is crucial especially if the variable is holding a dictionary.
Again, you have to set a new variable to the value of the old one and remove the old one. There is no way to rename a variable without changing the memory reference.