Help with color Change gui

I can’t see anything wrong here.
My only workaround would be to attempt to have the player break the input with ‘,’ to format it like ‘25,60,78’
Then use ‘string.split()’ to break the input into three values.

Im trying to make the flower’s head BrickColor change to the inputted one
For example
Box content = Bright red
part.BrickColor = BrickColor.new(box.Text)
I tried using tostring() but it still didnt work

I think your problem is possibly the if statement that checks if the flower is null. (if flower then)

You should add a print right after the if statement. Since FindFirstChild() will return null if the part you’re looking for does not exist.

I think “flowerhead” may not exist inside of Character when your if statement is being evaluated. Therefor, not changing the color.

Try this:

if flower then
    print("Found")
else
    print("Not found")
end

If “Not found” gets printed, then you’re flowerhead is missing inside the character model.

This is what happens when for example trying to change the flower’s head to Bright red https://gyazo.com/c01503eca1f553612a7f548fd4df2029

Could you try

flower.usePartColor = true
flower.BrickColor = BrickColor.new(box)

I know, I’m asking you to check if the flower is in fact being found by the script.

If the script can’t find the flower, it will skip the if statement condition.

Yes the flowers head is defined

Can you confirm that using a print(“”) inside the if statement?

It uses PartColor, otherwise it wouldnt affect the color

if flower then
	print("flower head found, player: "..flower.Parent.Name)
	flower.BrickColor = BrickColor.new(box)
end

https://gyazo.com/40da06293abc144265dcfecaf17cde71 the flower is defined as players head

2 Likes

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.