Help with color Change gui

Since you’re giving the input as a brick color…
Possibly try something like this?:

local Input = script.Parent.Parent.Color.Text
local ToColor = BrickColor.new(Input)

flower.BrickColor = ToColor

Perfect, so it’s not that.

Try printing the value of box.

print(box) and check what value is being passed in.

It just prints nothing

script.Parent.MouseButton1Click:Connect(function()
	local Input = script.Parent.Parent.Color.Text
	local ToColor = BrickColor.new(tostring(Input))
	print(Input, ToColor)
	wait()
	local flower = script.Parent.Parent.Parent.Parent.Parent.Character:FindFirstChild("flowerhead")
	if flower then
		print("flower head found, player: "..flower.Parent.Name)
		flower.BrickColor = ToColor
	end
end)

https://gyazo.com/37bdf50c8e600e3aba244d61b0f71d11 i noticed that i tried tostring nil

Ok, so your issue is with the value being passed in.

If you’re grabbing text from a text box. You can put it into a variable without having to call tostring(). Text is already a string.

Your script should look like this:

local inputcolor = MyTextBox.Text
flower.BrickColor = BrickColor.new(inputcolor)

Make sure you’re also referring to the correct TextBox.

script.Parent.MouseButton1Click:Connect(function()
	wait()
	local Input = script.Parent.Parent.Color.Text
	print(Input)
	local flower = script.Parent.Parent.Parent.Parent.Parent.Character:FindFirstChild("flowerhead")
	if flower then
		print("flower head found, player: "..flower.Parent.Name)
		flower.BrickColor = BrickColor.new(Input)
	end
end)

it still prints “” and changes it to gray

Are you sure that script.Parent.Parent.Color is a TextBox UI element?

Yes i am sure it refers to the TextBox

Is this code being done in a LocalScript or ServerScript?

If it’s being done in a ServerScript, the issue would be that the script cannot see the text being changed by the client. Therefor, it always remains “”.

To fix this issue, you can put your code inside a LocalScript. Then, send a RemoteEvent and ask the server to change the color of the flowerhead.

The RemoteEvent would be sending the TextBox.Text as its argument. So the server can use the input as the value of the color.

The code is being done by the server, if im sure i could use RemoteEvent but my only problem is it could be abused by exploiters

That is your issue then. When the client changes the text in a TextBox locally, it is not replicated to the server.

You need to figure out a way to show the server what text is being inputed.

Alright, i guess ill go with a RemoteEvent, i appreciate your help. Thanks!

No problem, an alternative (Which is a bit tedious), is to create a button for every possible BrickColor available. Then, have the user select which color they want instead of typing it. That way, the server doesn’t need to check for any text. Instead, it will check for a button click and color it accordingly.

script.BrightRed.MouseButton1Down:Connect(function()
    flower.BrickColor = BrickColor.new("Bright red")
end)

Yeah, the best thing you could do is use a remote event to send the input color to the server. On the server you could then verify if the provided color is of type Color3. If it is, you can set the color of whatever you wanna change. I’ve made something similar recently:
https://streamable.com/o4mxe9