Answered by
5 years ago Edited 5 years ago
You don't need to use remote events with click detectors, just use the .MouseClick
event from your detector in your server script like this:
Update: Since game.Workspace.Bedframe.Change
is a model, we can't call .BrickColor
directly on it, we have to loop through its children and change said property on each of them.
Update2: Change 'waitTime' to the number of seconds you want your parts to stay painted.
01 | local clickdetector = game.Workspace.Bedframe.Pinecone.ClickDetector |
04 | local color = "Pine Cone" |
05 | local origColor = "Buttermilk" |
07 | clickdetector.MouseClick:Connect( function (player) |
10 | for i, part in pairs (game.Workspace.Bedframe.Change:GetDescendants()) do |
11 | if part:IsA( "BasePart" ) then |
12 | part.BrickColor = BrickColor.new(color) |
16 | for i, part in pairs (game.Workspace.Bedframe.Change:GetDescendants()) do |
17 | if part:IsA( "BasePart" ) then |
18 | part.BrickColor = BrickColor.new(origColor) |