TextLabel not working

Hey Developers,
I am making a checkin. I have made it so that there is a configuration script, where the names of stuff are set.
Here is the config script:

settings.Class1Name = 'Economy'; 
settings.Class2Name = 'Business'; 
settings.Class3Name = 'First';
settings.Class4Name = 'Investor';

This is the local script:

if settings.ClassAmount == 3 then
	PurchaseSelect.Class4:Destroy()
	PurchaseSelect.Class2.ClassName.Text = settings.Class2Name
	PurchaseSelect.Class3.ClassName.Text = settings.Class3Name
elseif settings.ClassAmount == 4 then
	PurchaseSelect.Class2.ClassName.Text = settings.Class2Name
	PurchaseSelect.Class3.ClassName.Text = settings.Class3Name
	PurchaseSelect.Class4.ClassName.Text = settings.Class4Name

This is the error:
[13:58:25.230 - Players.Little_Joes.PlayerGui.SCIUI.ClientHandler:26: attempt to index string with ‘Text’]

Thanks for any help!

This is probably happening because you are using the name ‘ClassName’, this is a property of all instances on Roblox so developers can read what type of instance something is. To combat this, you could change:

PurchaseSelect.Class2.ClassName.Text = settings.Class2Name

to

PurchaseSelect.Class2["ClassName"].Text = settings.Class2Name

This is of course an example and you will have to change this on the other lines too. Let me know if this helps :slight_smile:

3 Likes