Using a click detector to change a brick's colour

This has been solved In apparently less than 3 minutes wow but you can still read it

Hi im having problems with how to use the click detector. I feel like I have done something wrong but i’m not sure what. What I want is to make a click-to-make-a-block-move-by-itself button. I am not asking for you to make a moving script i may ask that later as an edit or another topic post I’m trying to make it so that if I click the button, it will turn green. But nothing is working so i decided to ask the forum. I am on my test server btw

Properties

Capture4 Behind Model3 Is the workspace. I highlighted the important stuff

Script I have right now
local M3 = game.Workspace.Model3

M3.Lift.Model.CD.ClickDetector.MouseClick.OnClick:Connect(function()
	 M3.Lift.Model.CD.BrickColor = BrickColor.Green()
end)

The ‘OnClick’ thing doesn’t do anything.

local M3 = game.Workspace.Model3

M3.Lift.Model.CD.ClickDetector.MouseClick:Connect(function()
	 M3.Lift.Model.CD.BrickColor = BrickColor.Green()
end)
2 Likes

That’s actually false, BrickColor.Green() is a function and would work fine.

1 Like

Thank you, I guess I learned from this post too!

1 Like

The only reason you’re having an issue is because of OnClick it isn’t needed. Remove OnClick and connect to the MouseClick event instead

M3.Lift.Model.CD.ClickDetector.MouseClick.OnClick:Connect(

should be

M3.Lift.Model.CD.ClickDetector.MouseClick:Connect(

Also you can reference the part more directly with ‘script.Parent’

script.Parent.ClickDetector.MouseClick:Connect(function()
	script.Parent.BrickColor = BrickColor.Green()
end)
1 Like

bruh for some reason when i did that method by myself it didnt work so i tried the same exact thing of what i did earlier (what you said to do) and it worked now. This is really confusing but ty for your time everyone

i accepted his comment because it was the oldest and it worked