I’m trying to have two strings (“ImageLabel” and “ImageButton”) set to one string (“Image”) in a table but I don’t know how to do it. The way I’ve done it is incorrect and doesn’t work as I intended.
If you’re wondering, I’m using this for an asset loading system to preload all of the assets ingame (with ContentProvider) before the player spawns in.
Currently testing with a short line of code in the console:
local AssetTypes = {["ImageLabel" and "ImageButton"] = "Image"} local decal = Instance.new("ImageLabel"); print(AssetTypes[decal.ClassName]); decal:Destroy()
Neither of the trials will work, it Roblox, only single-indexes are possible so you can’t do this, your can try to either remove the clones or just have it there or, invert the tables so that the “Image” is the key and the value is a table containing “ImageLabel” and “ImageButton”
To help with your problem, the key evaluates to “ImageButton” so it’ll be:
local AssetTypes = {["ImageButton"] = "Image"}
That’s why it returned nil when u tried it with ImageLabel. Reason is, your using and which checks if the thing before it is true (or non-nil) and if so, will evaluate to the value after it, if not, it will look for an or if there is, it will evaluate to it, if not, it will evaluate to nil.