Need help with color changing script

(the script is for changing the name and color of the patty tool when it goes on top of the oven)
The name of the patty changes but not the color. I’ve been trying to make the color changing part of the script work for a while and this is what I have currently. I don’t really know how to script well yet so I don’t know what to do.

script.Parent.Touched:Connect(function (h)

   if h.Parent.Name == "Raw Patty" then
	 wait(5)
		h.Parent.Name = "Cooked Patty"
   end
	
	if h.Parent.Name== "Cooked Patty" then
		wait(0)
		h.Parent.BrickColor = BrickColor.new(95,64,50)
	end	

end)

this is a cry for help :cry:

You’re trying to set BrickColor to a RGB value, you need to use Color3 instead.

h.Parent.Color = Color3.fromRGB(95,64,50)

BrickColors are not what you are looking for. BrickColors include "institutional white", "dark stone grey" etc

Tried doing this instead right now but it still didn’t change the color

The first reply to this thread should solve your problem but here is a better way of how you could format your code -

script.Parent.Touched:Connect(function (h)
    if (h.Parent.Name == "Raw Patty") then
        task.wait(5) 
        h.Parent.Name = "Cooked Patty" 
        h.Parent.Color = Color3.new(95/255 , 64/255 , 50/255) 
    end
end)
1 Like

Are there any errors?

Also, can you show me a screenshot of the “Raw/Cooked Patty” explorer? like this

image

Not sure what you mean by I’ve been trying to make the color changing part do you want the part to be color changing as in RGB? or just changing the part to black or white?

put a print statment inside of that if statment, and see if it prints anything into the output and if there is any errors

I want to change it from the left color to the right color
image

image

Script inside of union
local part = script.Parent

local click = part.ClickDetector



local function pickup(player)

	local newTool = Instance.new('Tool')

	newTool.Name = 'Raw Patty'

	local handle = part:Clone()

	handle.Name = 'Handle'

	handle.Parent = newTool

	handle.Script:Destroy()

	newTool.Parent = game.Workspace[player.Name]

end



click.MouseClick:Connect(pickup)

p.s. I’ve just realized the issue is probably the fact that I’m trying to change the color of a tool (not sure if that’s possible or not)

Probably like that, Color/BrickColor can be only changed on union, part, etc.
When you touched something, It will return the part, so you can change the color of h without going to Its parent.

So this script should work.

script.Parent.Touched:Connect(function (h)
   if h.Parent.Name == "Raw Patty" then
	    wait(5)
	    h.Parent.Name = "Cooked Patty"
        h.Color = Color3.fromRGB(95,64,50) --color should change too since it's changes to "cooked patty"
   end
--[[
  if h.Parent.Name== "Cooked Patty" then
		wait(0)
		h.Color = Color3.fromRGB(95,64,50) --change color instead of brickcolor
	end	
]] -- the color already change with the name on statement one so it doesn't need to change again
   -- but you can add it back in case it doesn't work
end)

Did you make sure UsePartColor was enabled in the union?

Are you getting any errors? If so it would be helpful for you to send it

local Part = script.Parent

Part.Touched:Connect(function(Hit)
	if Hit.Name == "Raw Patty" then
		task.wait(5)
		Hit.Name = "Cooked Patty"
		Hit.BrickColor = BrickColor.new("Earth orange")
	end
end)

The Color3 value you specified is closest to the “Earth orange” BrickColor value.

Few questions which may answer yours. Firstly, is the “h.Parent” a model? If so, you can’t change the colour of a model so you might’ve overlooked that. Secondly, try h.Parent.Color = Color3.new(–RGBVALUE) as brickcolor takes in a string to change the colour, other than that I don’t see anything wrong with the script

TL;DR
Issue1: h.Parent could be a model which if so, you can’t change the colour of that. Same for if it’s a tool

Issue2: h.Parent.BrickColor takes in a string value, use h.Parent.Color = Color3.new(95, 64, 50) instead

Sorry for answering late, I haven’t been on my computer in a few days.
image
I’m going to try replacing the raw patty tool with a cooked patty tool instead of changing the name and color