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

subtracting r,g,b from a textlabels text?

Asked by
Plieax 66
6 years ago

I have this but it is always giving me an error on the textcolor.r = textcolor.r +1 part how do i fix?

local speed = .5
local this = script.Parent
local textcolor = this.TextColor3
local color1 = Color3.new(255,0,0)
local color2 = Color3.new(0,0,255)


repeat

    textcolor.r = textcolor.r +1
    textcolor.b = textcolor.b -1

    wait(speed) 

until this.TextColor3 == color1
0
What's the error? KingLoneCat 2642 — 6y
0
`RColour = RColour + (1/255)`? TheeDeathCaster 2368 — 6y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

The r,g, and b values of a Color3 are read-only, meaning that attempting to assign to assign a value to it will return an error.

Also, Color3.new's values are supposed to be between 0 and 1.

local speed = 5
local this = script.Parent
local textcolour = this.TextColor3
local colour1 = Color3.new(1,0,0)
local colour2 = Color3.new(0,0,1)

local r = textcolor.r
local b = textcolor.b

repeat
    r = r + 1
    b = b - 1
    this.TextColor3 = Color.new(r/255,0,b/255)
    wait(speed)
until this.TextColor3 == colour1
0
this doesnt work either Plieax 66 — 6y
Ad

Answer this question