Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't TextColor3 want to work?

I am trying to make it change the color of the text that's on the surfacegui, everything else is fine but the color won't change, and it sucks that there is no error code because i can't fix it without an error

Code:

local board = game.Workspace:WaitForChild("Board")
local scriptablepart = board:WaitForChild("Scriptable")
local sgui = scriptablepart:WaitForChild("SurfaceGui")

local homeworktext = sgui:WaitForChild("HomeworkTitle"):WaitForChild("Homework")
local assignmenttext = sgui:WaitForChild("AssignmentTitle"):WaitForChild("Assignment")
local notetext = sgui:WaitForChild("TeachersNoteTitle"):WaitForChild("Note")

local editedtext = script.Parent:WaitForChild("EditedText")
local writeonboard = script.Parent:WaitForChild("WriteOnBoard")

local currentcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("CurrentColor")

local blackcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Black")
local bluecolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Blue")
local yellowcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Yellow")
local redcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Red")
local greencolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Green")

local color = "Black"
local colorforcoding = "0,0,0"
currentcolor.Text = "Current: "..color.." "..colorforcoding

writeonboard.MouseButton1Click:connect(function()
	homeworktext.TextColor3 = Color3.fromRGB(colorforcoding)
	homeworktext.Text = editedtext.Text
end)

blackcolor.MouseButton1Click:connect(function()
	color = "Black"
	colorforcoding = "0,0,0"
	currentcolor.Text = "Current: "..color.." "..colorforcoding
end)

bluecolor.MouseButton1Click:connect(function()
	color = "Blue"
	colorforcoding = "0,0,255"
	currentcolor.Text = "Current: "..color.." "..colorforcoding
end)

yellowcolor.MouseButton1Click:connect(function()
	color = "Yellow"
	colorforcoding = "255,255,0"
	currentcolor.Text = "Current: "..color.." "..colorforcoding
end)

redcolor.MouseButton1Click:connect(function()
	color = "Red"
	colorforcoding = "255,0,0"
	currentcolor.Text = "Current: "..color.." "..colorforcoding
end)

greencolor.MouseButton1Click:connect(function()
	color = "Green"
	colorforcoding = "0,255,0"
	currentcolor.Text = "Current: "..color.." "..colorforcoding
end)

1 answer

✓ Accepted answer

Try this code:

local board = game.Workspace:WaitForChild("Board")
local scriptablepart = board:WaitForChild("Scriptable")
local sgui = scriptablepart:WaitForChild("SurfaceGui")

local homeworktext = sgui:WaitForChild("HomeworkTitle"):WaitForChild("Homework")
local assignmenttext = sgui:WaitForChild("AssignmentTitle"):WaitForChild("Assignment")
local notetext = sgui:WaitForChild("TeachersNoteTitle"):WaitForChild("Note")

local editedtext = script.Parent:WaitForChild("EditedText")
local writeonboard = script.Parent:WaitForChild("WriteOnBoard")

local currentcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("CurrentColor")

local blackcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Black")
local bluecolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Blue")
local yellowcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Yellow")
local redcolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Red")
local greencolor = script.Parent:WaitForChild("ColorsTitle"):WaitForChild("Green")

local color = "Black"
local colorforcoding = Color3.fromRGB(0,0,0)
currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)

writeonboard.MouseButton1Click:connect(function()
    homeworktext.TextColor3 = colorforcoding
    homeworktext.Text = editedtext.Text
end)

blackcolor.MouseButton1Click:connect(function()
    color = "Black"
    colorforcoding = Color3.fromRGB(0,0,0)
    currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)
end)

bluecolor.MouseButton1Click:connect(function()
    color = "Blue"
    colorforcoding = Color3.fromRGB(0,0,255)
    currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)
end)

yellowcolor.MouseButton1Click:connect(function()
    color = "Yellow"
    colorforcoding = Color3.fromRGB(255,255,0)
    currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)
end)

redcolor.MouseButton1Click:connect(function()
    color = "Red"
    colorforcoding = Color3.fromRGB(255,0,0)
    currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)
end)

greencolor.MouseButton1Click:connect(function()
    color = "Green"
    colorforcoding = Color3.fromRGB(0,255,0)
    currentcolor.Text = "Current: "..color.." "..tostring(colorforcoding)
end)

3 comments

0

Make sure to leave an upvote if I helped ^.^

1

Explain your code! What was the asker doing wrong, and how did you fix it?

0

For clarification, you should not use a string in Color3.fromRGB, nor any Color3 type. However, you can transfer Color3 into a string using tostring(). What I did was have the colorforcoding value be the actual Color3 value and then have the text convert that Color3 into a string for display.

This discussion is preserved as it was. New answers, comments, and votes are closed.