Making part change it's color

So, i tried to make a part change it’s color on click, but it didn’t work
Script’s contenents:

if script.Parent.ClickDetector.MouseClick
	local BrickColor = (141)
end

explorer: Screenshot_66

2 Likes

You have to connect a function to the ClickDetector’s MouseClick event, like so:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    script.Parent.BrickColor = BrickColor.new("Really Red")
    -- or
    script.Parent.Color = Color3.new(255, 0, 0) -- use RGB
end)
3 Likes

Change it to script.Parent.BrickColor = BrickColor.new(141)

1 Like
local part = workspace.Part
local clickDetector = part.ClickDetector

function onClick()
        part.Color = Color3.new(144,0,0)   --You have to use RGB in order to work so change the 144 to each 0 until you get to the wanted color
end

clickDetector.MouseClick:Connect(onClick)

This should work

Thanks for the help everyone, i forgot to mention that i’m still very new to scripting.

2 Likes

Just keep practicing and you’ll be good!

You can check the many tutorials on youtube, or the Developer Hub for great knowledge.