|
| 20 Jan 2012 03:56 PM |
I wrote this out, it doesn't seem to be working.
Could anyone help me? If so, that'd be awesome.
x = script.Parent.GenColor
function onClicked()
if x.BrickColor = "Lime green" then x.BrickColor = "Bright red" while true do script.Parent.val.Value + 1 wait(10) end
elseif x.BrickColor = "Bright red" then x.BrickColor = "Lime green" while true do script.Parent.val.Value + 1 wait(10) end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Nothing on output. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:00 PM |
if x.BrickColor == BrickColor.new("Lime green") then
I think... † KMXD † |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 20 Jan 2012 04:02 PM |
When comparing, use '==' not '='.
if x.BrickColor = "Lime green" then
should be..
if x.BrickColor == "Lime green" then
Do the same for the elseif statement to. I didn't look over it closely, that was the only error that stood out. By the way, what is GenColor? |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:04 PM |
x.BrickColor is a userdata. Knightmare's method is correct. Here's an alternative approach:
if tostring(x.BrickColor) == "Lime green" then
OR
if x.BrickColor.name == "Lime green" then |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 20 Jan 2012 04:04 PM |
| Use knightmare's, I thought you only needed BrickColor.new("Colour") when you were changing colours, not checking. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:07 PM |
The only reason the == operator works on BrickColor values is because of the __eq metamethod in each of the BrickColor userdatas. Here's what __eq looks like:
__eq = function(Comp1, Comp2) local X = pcall(function() return Comp1.name end) local X2 = pcall(function() return Comp2.name end) if X and X2 then if Comp1.name == Comp2.name then return true end end return false end
The pcalls are there to check if the property name actually exists. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:14 PM |
Still doesn't seem to work.
This is what I now have;
x = script.Parent.GenColor
function onClicked()
if x.BrickColor.name == "Lime green" then x.BrickColor = "Bright red" while true do script.Parent.val.Value + 1 wait(10) end end elseif x.BrickColor.name == "Bright red" then x.BrickColor = "Lime green" while true do script.Parent.val.Value + 1 wait(10) end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jan 2012 04:24 PM |
| Sorry, use capital N. BrickColor.Name |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:27 PM |
Oh, haha.
I was wondering if that was it, but you wrote it like that.
Thanks! |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2012 04:32 PM |
This also is wrong-
x.BrickColor = "Bright red"
should be...
x.BrickColor = BrickColor.new("Bright red") --need to use BrickColor.new() |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 01:13 PM |
Still doesn't seem to be working. Nothing on output:
x = script.Parent.GenColor
function onClicked()
if x.BrickColor.Name == "Lime green" then x.BrickColor = BrickColor.new("Bright red") while true do script.Parent.val.Value + 1 wait(10) end elseif x.BrickColor.Name == "Bright red" then x.BrickColor = BrickColor.new("Lime green") while true do script.Parent.val.Value + 1 wait(10) end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 01:23 PM |
| Could someone please help? |
|
|
| Report Abuse |
|
|
ExoCross
|
  |
| Joined: 26 Jan 2011 |
| Total Posts: 179 |
|
|
| 21 Jan 2012 01:25 PM |
Change both "script.Parent.val.Value + 1" To:
script.Parent.val.Value = script.Parent.val.Value + 1 |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 01:30 PM |
Didn't fix it.
Is there something wrong with my "ends?" |
|
|
| Report Abuse |
|
|
ExoCross
|
  |
| Joined: 26 Jan 2011 |
| Total Posts: 179 |
|
| |
|
ExoCross
|
  |
| Joined: 26 Jan 2011 |
| Total Posts: 179 |
|
|
| 21 Jan 2012 01:32 PM |
| Eh, nevermind, you have enough. Any output? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 21 Jan 2012 10:59 PM |
I'd suggest comparing BrickColors instead of strings-
if x.BrickColor.Name == "Lime green" then
instead do...
if x.BrickColor == BrickColor.new("Lime green") then |
|
|
| Report Abuse |
|
|