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 5 years ago
Edited 5 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.

Wo0t = script.Parent
Wo0t.BackgroundTransparency = 1
Wo0t.TextSize = {0, 800},{0, 600}
Wo0t.TextScaled = 1
while true do
    Wo0t.TextColor3 = ("[0,255,255]")
    Wo0t.Text = (" ")
    wait (0.2)
    Wo0t.Text = ("W")
    wait (0.2)
    Wo0t.Text = ("We")
    wait (0.2)
    Wo0t.Text = ("Wel")
    wait (0.2)
    Wo0t.Text = ("Welc")
    wait (0.2)
    Wo0t.Text = ("Welco")
    wait (0.2)
    Wo0t.Text = ("Welcom")
    wait (0.2)
    Wo0t.Text = ("Welcome")
    wait (0.2)
    Wo0t.Text = ("Welcome!")

    wait (1)
    Wo0t.TextColor3 = ("[0,0,255]")
    Wo0t.Text = ("Welcome")
    wait (0.2)
    Wo0t.Text = ("Welcom")
    wait (0.2)
    Wo0t.Text = ("Welco")
    wait (0.2)
    Wo0t.Text = ("Welc")
    wait (0.2)
    Wo0t.Text = ("Wel")
    wait (0.2)
    Wo0t.Text = ("We")
    wait (0.2)
    Wo0t.Text = ("W")
    wait (0.2)
    Wo0t.Text = (" ")
    wait (0.5)
end
print ("Hello from mariofl2003!")
0
Don't forget to accept my answer if it helps. User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by 5 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.

local Wo0t = script.Parent -- use local variables 
Wo0t.BackgroundTransparency = 1
Wo0t.TextScaled = 1
local goal = "Welcome!"

while true do
    Wo0t.TextColor3 = Color3.fromRGB(0, 255, 255)
    for i = 1, #goal do
        Wo0t.Text = string.sub(goal 1, i)
        wait(0.2)
    end
    wait (1)
    Wo0t.TextColor3 = Color3.fromRGB(0, 0, 255)
    for i = #goal, 1, -1 do
        Wo0t.Text = string.sub(goal, 1, i)
        wait(0.2)
    end
    Wo0t.Text = ""
    wait(0.5)
end
print("Hello from mariofl2003!")

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 — 5y
Ad

Answer this question