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

How would I turn the text that a player inputs in a textbox into a Color3Value's value?

I am trying to get the text (the player will have to input something like "255,0,0" into the textbox) and turn it into a color3value, how would I do that? The output keeps saying it expecting a color value but receives a string or something along those lines.

advancedframe.Update.MouseButton1Down:connect(function()
	local colori = advancedframe.IColor.Text
	for i = 1,#colori do
		values.Color.Value = Color3.new(colori:sub(i/255,i/255,i/255))
	end
end)

1 answer

Your code doesn't make sense at all so I won't comment on it. You need a more complex loop which utilizes string manipulation.

local text = textbox.Text
local nums = {}
for str in string.gmatch(text,"%d+") do --find each number
	table.insert(nums,tonumber(str)) --put in table
end
--now you have every number
--convert table to color3
values.Color.Value = Color3.fromRGB(unpack(nums)) 
--done!

2 comments

0

Thanx :)

0

Please accept the answer ? :)

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