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

How to fix color-changeable textbox script?(Output Error)

Asked by 6 years ago
Edited 6 years ago

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.

01Wo0t = script.Parent
02Wo0t.BackgroundTransparency = 1
03Wo0t.TextSize = {0, 800},{0, 600}
04Wo0t.TextScaled = 1
05while true do
06    Wo0t.TextColor3 = ("[0,255,255]")
07    Wo0t.Text = (" ")
08    wait (0.2)
09    Wo0t.Text = ("W")
10    wait (0.2)
11    Wo0t.Text = ("We")
12    wait (0.2)
13    Wo0t.Text = ("Wel")
14    wait (0.2)
15    Wo0t.Text = ("Welc")
View all 44 lines...
0
Don't forget to accept my answer if it helps. User#24403 69 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

01local Wo0t = script.Parent -- use local variables
02Wo0t.BackgroundTransparency = 1
03Wo0t.TextScaled = 1
04local goal = "Welcome!"
05 
06while true do
07    Wo0t.TextColor3 = Color3.fromRGB(0, 255, 255)
08    for i = 1, #goal do
09        Wo0t.Text = string.sub(goal 1, i)
10        wait(0.2)
11    end
12    wait (1)
13    Wo0t.TextColor3 = Color3.fromRGB(0, 0, 255)
14    for i = #goal, 1, -1 do
15        Wo0t.Text = string.sub(goal, 1, i)
View all 21 lines...

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.

0
Thanks! That fixed my problem! mariofl2003 11 — 6y
Ad

Answer this question