I was writing an script, so it gonna write text, and it will change color. And when I was done it, I got Output error Screenshot of error - https://imgur.com/CgNfcKj Heres the script.
01 | Wo 0 t = script.Parent |
02 | Wo 0 t.BackgroundTransparency = 1 |
03 | Wo 0 t.TextSize = { 0 , 800 } , { 0 , 600 } |
04 | Wo 0 t.TextScaled = 1 |
05 | while true do |
06 | Wo 0 t.TextColor 3 = ( "[0,255,255]" ) |
07 | Wo 0 t.Text = ( " " ) |
08 | wait ( 0.2 ) |
09 | Wo 0 t.Text = ( "W" ) |
10 | wait ( 0.2 ) |
11 | Wo 0 t.Text = ( "We" ) |
12 | wait ( 0.2 ) |
13 | Wo 0 t.Text = ( "Wel" ) |
14 | wait ( 0.2 ) |
15 | Wo 0 t.Text = ( "Welc" ) |
The error is pretty self explanatory it expects a Color3 value when you gave it a string. You can construct a Color3 with the Color3.new
or Color3.fromRGB
functions.
The former takes numbers ranging from [0, 1] and the latter takes numbers from [0, 255]
By the way instead of manually setting the text to something new use the string.sub function instead.
01 | local Wo 0 t = script.Parent -- use local variables |
02 | Wo 0 t.BackgroundTransparency = 1 |
03 | Wo 0 t.TextScaled = 1 |
04 | local goal = "Welcome!" |
05 |
06 | while true do |
07 | Wo 0 t.TextColor 3 = Color 3. fromRGB( 0 , 255 , 255 ) |
08 | for i = 1 , #goal do |
09 | Wo 0 t.Text = string.sub(goal 1 , i) |
10 | wait( 0.2 ) |
11 | end |
12 | wait ( 1 ) |
13 | Wo 0 t.TextColor 3 = Color 3. fromRGB( 0 , 0 , 255 ) |
14 | for i = #goal, 1 , - 1 do |
15 | Wo 0 t.Text = string.sub(goal, 1 , i) |
string.sub(str, starting, ending)
basically returns the substring (portion of a string) at starting
until ending
, so string.sub("Hello world!", 7, 11) == "world"
. You can find more on this by doing a google search.