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

Finding BackgroundColor3 returns as nothing? Help!

Hello! I am making a picture to richtext gui (drawn by hand) and when I try to export it, it returns as blank (rgb())! Can anyone help?

function LineText(li,un)
	local LineSource = ""
	
	local a = "",li.a.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.b.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.c.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.d.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.e.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.f.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.g.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.h.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.i.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.j.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.k.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.l.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.m.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.n.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.o.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.p.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.q.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.r.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.s.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	local a = "",li.t.BackgroundColor3
	LineSource = LineSource..'<font color="rgb('..a..')">'..un.."</font>\n"
	return LineSource
end

function EXPORT(Unicode)
	local Source = ""
	local Pal = script.Parent.Parent.Parent.Parent.Palette
	
	Source = Source.."\n"..LineText(Pal.r1,Unicode)
	Source = Source.."\n"..LineText(Pal.r2,Unicode)
	Source = Source.."\n"..LineText(Pal.r3,Unicode)
	Source = Source.."\n"..LineText(Pal.r4,Unicode)
	Source = Source.."\n"..LineText(Pal.r5,Unicode)
	Source = Source.."\n"..LineText(Pal.r6,Unicode)
	Source = Source.."\n"..LineText(Pal.r7,Unicode)
	Source = Source.."\n"..LineText(Pal.r8,Unicode)
	Source = Source.."\n"..LineText(Pal.r9,Unicode)
	Source = Source.."\n"..LineText(Pal.r10,Unicode)
	Source = Source.."\n"..LineText(Pal.r11,Unicode)
	Source = Source.."\n"..LineText(Pal.r12,Unicode)
	Source = Source.."\n"..LineText(Pal.r13,Unicode)
	Source = Source.."\n"..LineText(Pal.r14,Unicode)
	Source = Source.."\n"..LineText(Pal.r15,Unicode)
	Source = Source.."\n"..LineText(Pal.r16,Unicode)
	Source = Source.."\n"..LineText(Pal.r17,Unicode)
	Source = Source.."\n"..LineText(Pal.r18,Unicode)
	Source = Source.."\n"..LineText(Pal.r19,Unicode)
	Source = Source.."\n"..LineText(Pal.r20,Unicode)
	
	return Source
end

script.Parent.OnServerEvent:Connect(function(p,un)
	print(EXPORT(un))
end)

Edit: Explorer, and UI.

5 comments

0

Cool, have not seen this before, can you explain a bit more what it is supposed to do? You are making a picture to rich text that was drawn by hand???

0

Im not really shure, it looks like your using Java script.

0

Also set a to: a=li.a.BackgroundColor3

0

you can repost questions after 3 days

0

Jailbreaker: He wants to convert pictures to colored ascii art. SharkOwen: It's HTML Richtext API.

2 answers

So, it looks like you're exporting as a string. Effectively what you are doing is opening and closing the string at the wrong places. I'm surprised the color change didn't throw you off.

You needed an escape char: www.lua.org/pil/2.4.html

--Here you can see what's happening:
LineSource..    --string
'<font color="   --string
rgb('..a..')     	--function with string input
">'    		--string
..un..		--string
"</font>\n"	--string

--should be:
 LineSource.."<font color=\"rgb("..a..")\""..un.."</font>\n"

--Which looks like:
LineSource..
"<font color=\"rgb("
..a..
")\""
..un..
"</font>\n"

1 comment

0

This still returns as rgb()

local AsciiArt -- "Localize" it

local function CreateRichtextObject(Color, Text) -- Define function
    return string.format("<font color=\"rgb('%i, %i, %i')\">%s</font>", Color.R*255, Color.G*255, Color.B*255, Text) -- Make it colorful
end

local function PalletteToString(Pallette, Character) -- Define function
    AsciiArt = "" -- set to empty string
    for Row = 1, 20 do -- Loop through rows
        for Column = 1, 20 do -- Loop through columns
            AsciiArt = AsciiArt .. CreateRichtextObject(Pallete["r"..Row][utf8.char(Column+96)].BackgroundColor3, Character) -- Get the bg color and character
        end
        AsciiArt = AsciiArt .. "\n" -- Add newlins
    end
end

script.Parent.OnServerEvent:Connect(function(Player, Character) -- connect to event i guess
    print(PalletteToString(script.Parent.Parent.Parent.Parent.Palette, Character)) -- pls shorten script.Parent.Parent.Parent.Parent
end)

Any questions? Ask and I'll answer tomorrow

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