For example, I have a brick that when you click it once, the color is red, you click it a second time and it's yellow, a third time it's blue and the fourth time it goes back to red and the cycle repeats. How can I archieve this?
As Ponytails2017 said, this is not a request site. As you did make an effort to post your attempts, I am happy to help. Just remember in the future to follow the guildelines.
01 | local clickDetector = script.Parent -- instance of ClickDetector |
02 | local uses = 0 |
03 |
04 | clickDetector.MouseClick:Connect( function (player) |
05 | uses = uses + 1 |
06 | if uses = = 1 then |
07 | clickDetector.Parent.BrickColor = BrickColor.new( "Bright red" ) |
08 | elseif uses = = 2 then |
09 | clickDetector.Parent.BrickColor = BrickColor.new( "Baby blue" ) |
10 | uses = 0 -- reset the count after the 2 clicks to continue checking |
11 | end |
12 | end ) |
You should check this out for more information: ClickDetector API
EDIT
I noticed I forgot to change 'script.Parent.BrickColor' to 'clickDetector.Parent.BrickColor'. It has been fixed.
write a variable called uses or something
01 | local uses = 0 |
02 | if uses = = 1 then |
03 | uses + = 1 |
04 | (change color here) |
05 | elseif uses = = 2 then |
06 | uses + = 1 |
07 | (change color here) |
08 | elseif uses = = 3 then |
09 | uses + = 1 |
10 | (change color here) |
11 | end |
12 |
13 | -- and repeat, inset this inside of the click detector function |
This is not a request site dude, try it first then if it doesn't work we can help you. https://scriptinghelpers.org/help/community-guidelines
Tried to make it myself, but this doesn't work still.
01 | while wait( 1 ) do |
02 | local value = 0 |
03 | if value = = 0 then |
04 | script.Parent.BrickColor = BrickColor.new( "Bright red" ) |
05 | value = value + 1 |
06 | end |
07 | if value = = 1 then |
08 | script.Parent.BrickColor = BrickColor.new( "Bright yellow" ) |
09 | value = value + 1 |
10 | end |
11 | if value = = 2 then |
12 | script.Parent.BrickColor = BrickColor.new( "Baby blue" ) |
13 | value = value - 1 |
14 | end |
15 | end |