Color not working

(keep in mind that i am very new to programming i started like 2 days ago so i may not understand very basic things) so basically, im trying to make a game where you can draw (my first game), but the color is not working

  1. What do you want to achieve? Keep it simple and clear!
    i want it to make it so that when a player clicks a color, the player can draw with that
  2. What is the issue? Include screenshots / videos if possible!
    the color just doesnt work, sets to black instead
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i did look on the developer forum, but there was nothing

ive tried this so far (current version):

(regular script in server script service)

local partsFolder = workspace:WaitForChild("Parts")
local colorButtons = game.StarterGui.ScreenGui.Frame
local colorchosen = "#000000"

-- sorry if this next bit is too unoptimized, i dont know much

	if colorButtons.Red.Activated then
		colorchosen = "#FF0000"
		print(colorchosen)
	elseif colorButtons.Orange.Activated  then
		colorchosen = "#FF5F14"
		print(colorchosen)
	elseif colorButtons.Yellow.Activated then
		colorchosen = "#FFE600"
		print(colorchosen)
	elseif colorButtons.Green.Activated then
		colorchosen = "#45DB00"
		print(colorchosen)
	elseif colorButtons.LightBlue.Activated then
		colorchosen = "#00FFE1"
		print(colorchosen)
	elseif colorButtons.Blue.Activated then
		colorchosen = "#008CFF"
		print(colorchosen)
	elseif colorButtons.Pink.Activated then
		colorchosen = "#FF00FF"
		print(colorchosen)
	elseif colorButtons.Purple.Activated then
		colorchosen = "#BF00FF"
		print(colorchosen)
	elseif colorButtons.White.Activated then
		colorchosen = "#FFFFFF"
		print(colorchosen)
	elseif colorButtons.Black.Activated then
		colorchosen = "#000000"	
		print(colorchosen)
end

	
local function changePartColor(part)
	print("Changing color of part:", part.Name, "to color:", colorchosen)
	part.Color = Color3.new(colorchosen)
	print("New color of part:", part.Name, "is:", part.Color)
end

for _, part in ipairs(partsFolder:GetChildren()) do
	if part:IsA("BasePart") then
		local clickDetector = Instance.new("ClickDetector")
		clickDetector.Parent = part

		clickDetector.MouseClick:Connect(function(player)
			changePartColor(part)
		end)
	end
end


and this:

(regular script in the color text buttons)

local button = script.Parent

local function colorchange()
	colorchosen = "(the hex value here)"
end

button.MouseButton1Click:Connect(colorchange())

-- also in the other script in this version is basically the same but without the long bit
6 Likes

these are the buttons btw
image

3 Likes

Assuming these are Buttons, Activated is not a boolean, it will not tell you if it was fired or not, it can only fire code when it was fired because its an Event, for that you need to :Connect() it.

3 Likes

oh ok, let me try that ill respond in a bit

3 Likes

it still doesnt work, it just changes the color of the parts to red (the default color)

3 Likes

it still does not work, it just changes the color of the parts to red, which is the default

3 Likes

still does not work, it just changes the color of the parts to red, which is the default color there are also no errors

3 Likes

Have you tried using the RGB values instead of Hex codes?
So an example of this if you didn’t know is

Color3.new(1,0,0) --This would be red

Also I’m not totally sure that hex codes even work the way you’re using them

2 Likes

i tried but i dont know how to put a Color3 value in a variable (i also tried a table)

1 Like

It’s the same way you would do so with other variables, variables aren’t just refined to strings, replace the hex codes with Color3 values of your choice.

2 Likes

ok, let me try (post limit bla bla bla)

2 Likes

maybe try using part.BrickColour = BrickColor.new(red, green, blue) instead of part.Color?

2 Likes

A brickcolor value requires a string not RBG values

2 Likes

yeah but brick color doesnt work with rgb

2 Likes

it does work with rgb

try it out

there an error, it says: 22:47:05.415 ServerScriptService.Script:3: attempt to call a table value - Server - Script:3

1 Like

Also instead of checking to see if every single button is being pressed just do this

Go to each button and create a Color3Value with your desired color
image

for i, Button in pairs(colorButtons:GetChildren()) do
     if Button:IsA("TextButton") then
          Button.MouseButton1Click:Connect(function()
               colorchosen = Button.ButtonColor.Value
          end)
     end
end
1 Like

i think its breaking because youre using hexadecimal?

i change from : color3.FromHex to color3.new

im gonna try
(30. abcabcabcabc)