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

Why doesn't TextColor3 want to work?

Asked by
sad_eyez 162
7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)
0
Make sure to leave an upvote if I helped ^.^ joritochip 705 — 7y
1
Explain your code! What was the asker doing wrong, and how did you fix it? M39a9am3R 3210 — 7y
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. joritochip 705 — 7y
Ad

Answer this question