Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to change textlabel text color with a variable?

Asked by 3 years ago

basically just trying to change the text in the text label with a variable. this is the error

attempt to index string with 'TextColor'

local color = character.UpperTorso.BrickColor
TextLabel.Text.TextColor3 = color
1
BrickColors have a Color property. Fifkee 2017 — 3y

2 answers

Log in to vote
1
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Problem

You're attempting to index a string with a function, this would not work because functions cant be referenced by a string. - Unless with a type of function.

Another problem is that you cannot use BrickColors with a text. Because a brickcolor is a property of a 3D dimensional object.

Solution:

You'd have to use this function to change textlable colors. TextLable.TextColor3.

Fixed script

local color = character.UpperTorso.Color3
TextLabel.TextColor3 = color
0
ah, ok I see what I messed up on. the error I'm getting now is "Color3 is not a valid member of MeshPart" SWBTyresse 50 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

You can't mix BrickColor and Color3 together, as it would break your script. Instead, get the Color3 values from the character and then use TextLabel.TextColor3

local color = character.UpperTorso.Color3 --This gets 3 values.
TextLabel.TextColor3 = color

Answer this question