Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a part change color by clicking it?

Here's what I have

workspace.Part.playerWhoClicked = script.Parent.Parent.BrickColor.BrickColor.new("Bright red")

and also it comes up with no error, please help I would appreciate it.

1 comment

0

What is "playerWhoClicked"? If it's a ClickDetector, you should wrap the code in a "ClickDetector.MouseClick:Connect(function))" event, don't forget to end the function with "end)"

4 answers

✓ Accepted answer

Not sure what your script suppose to do, the syntax for your script is wrong, i think you should go back to basic

But this is what you need if you want to detect clicks on a brick https://developer.roblox.com/en-us/api-reference/class/ClickDetector

4 comments

0

-1 for "the syntax for your script is wrong, i think you should go back to basic". This syntax is perfectly valid. It's the implementation that is wrong.

0

thanks

0

@programmerHere Oh just fudge off, are you simon cowell of anwers or something? Get something better to do than going around trying to find faults in others e.g actually helping people., Its not like my solution to his problem is wrong, you don't just use BrickColor.new on a property,

0

It's not syntax issue lol, look up the definition of syntax. If nobody does quality control who will? No wonder you have -9 votes

This could be a simple fix.

game.Workspace.Part.ClickDetector.MouseClick:Connect(function()
	game.Workspace.Part.BrickColor = BrickColor.new("Bright red)
end)

go ahead and copy paste it.

I don't really know what the code is that you posted, but let's walk through this as if you were new to coding. If you wanted to detect a click on a model/part, then you need to use a "ClickDetector", so if you do not have it, then you insert one into the part.

*Steps: *

  1. Insert a Script and ClickDetector into the Part
  2. Edit the code to execute your goal
local ClickDetector = script.Parent:WaitForChild("ClickDetector") -- Index the ClickDetector

ClickDetector.MouseClick:Connect(function() -- Listen for a click
	script.Parent.BrickColor = BrickColor.random() -- Make the part a random color
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.