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

how do i make the gui text box text change the frames color?

i am making a customization for a sword, and i want the frame under the text box to change color to the text, but it wouldn't do it. i had the same problem with the brick color for the sword.


frame script:


frame = script.Parent.Parent

color = script.Parent.Text

frame.BackgroundColor3 = Color3.new(color)


Brick Script:


blade = game.StarterPack.GOBLIN.big

color = script.Parent.Text

blade.BrickColor = BrickColor.new(color)

3 comments

0

Server script or local?

0

Do you type the name of the color (BrickColor), or the value of the color(Color3)? Also note your scripts only run once, and it runs when the game runs.

0

Local, color3

1 answer

You cannot use strings to set Color3 values, they must all be numbers. For my game, I created a function which can convert strings to Color3 values, here is a snippet of the function which I used.

It basically just gets all the digits in the string and inserts it into a table which you can unpack and set the Color3 value there.

local ColorTab = {}

local function returnColor(color)
	for i in string.gmatch(color, '%d+') do
		local newi = tonumber(i)
		table.insert(ColorTab, newi)
	end
	table.concat(ColorTab, ', ')
end

returnColor('155, 255, 255') -- an example, you can just insert the text here

script.Parent.BackgroundColor3 = Color3.fromRGB(ColorTab[1], ColorTab[2], ColorTab[3])

1 comment

0

it didnt work

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