H1M
|
  |
| Joined: 11 Apr 2009 |
| Total Posts: 218 |
|
|
| 20 Nov 2012 06:17 AM |
Ok so I just got into lua, and I am trying to make a script so that when you hit a brick it changes color.... but if it is already that color.. I want it to change in to another color...
this is tha script I am using.
function onTouched(part)
if script.Parent.BrickColor == ("Toothpaste")
then script.Parent.BrickColor = BrickColor.new("Bright blue") else
script.Parent.BrickColor = BrickColor.new("Toothpaste")
end
end
script.Parent.Touched:connect(onTouched)
Can any one help me? |
|
|
| Report Abuse |
|
|
awas3
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 2854 |
|
|
| 20 Nov 2012 06:31 AM |
debounce = false
function onTouched() if debounce == false then debounce = true if script.Parent.BrickColor == BrickColor.new("Toothpaste") then script.Parent.BrickColor = BrickColor.new("Bright blue") else script.Parent.BrickColor = BrickColor.new("Toothpaste") wait(2) debounce = false end end end
script.Parent.Touched:connect(onTouched)
--The script will work every 2 seconds. When you touch the part once, it will take 2 seconds before you can touch it again
~A3~ |
|
|
| Report Abuse |
|
|
H1M
|
  |
| Joined: 11 Apr 2009 |
| Total Posts: 218 |
|
| |
|