Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
bailley5 114
4 years ago

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.

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)" MArzalAlBuchariZ 33 — 4y

4 answers

Log in to vote
-1
Answered by 4 years ago

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

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. programmerHere 371 — 4y
0
thanks bailley5 114 — 4y
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, Azure_Kite 885 — 4y
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 programmerHere 371 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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.

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
Log in to vote
0
Answered by
KingDomas 153
4 years ago

Roblox has a nice guide on this already. Here. https://developer.roblox.com/en-us/articles/introduction-to-input Just change the variables, etc. and the brick color at the bottom, and it should work.

Answer this question