|
| 28 Jan 2012 10:00 PM |
So I made a script where you click a brick, and the value of something goes up by one evrey ten seconds. You click it again, it goes down. This is the part that makes it go up.
while true do script.Parent.val.Value = script.Parent.val.Value + 1 wait(10) end
Every time it goes up, it immediately goes back to 0. What's wrong?
Any help would be nice. Thanks. |
|
|
| Report Abuse |
|
|
|
| 28 Jan 2012 10:01 PM |
| You lost me at "I made a script" |
|
|
| Report Abuse |
|
|
|
| 28 Jan 2012 10:02 PM |
Please only post if you're going to help. Here's the entire script if you want.
x = script.Parent.Parent.GenColor
function onClicked()
if x.BrickColor == BrickColor.new("Lime green") then x.BrickColor = BrickColor.new("Really red") while true do script.Parent.val.Value = script.Parent.val.Value - 1 wait(10) end
elseif x.BrickColor == BrickColor.new("Really red") then x.BrickColor = BrickColor.new("Lime green") while true do script.Parent.val.Value = script.Parent.val.Value + 1 wait(10) end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
|
| 28 Jan 2012 10:06 PM |
Well, can that work past 100?
Or no? |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
|
| 28 Jan 2012 10:10 PM |
| Well, if I set it to green, and it started adding, then set it to red at five, would it reset it the "i=1,100" back to one? |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 28 Jan 2012 10:28 PM |
local x = script.Parent.Parent.GenColor local booleanValue = nil function onClicked(playerObject) if x.BrickColor == BrickColor.new("Lime green") then x.BrickColor = BrickColor.new("Really red") booleanValue = false while not booleanValue do script.Parent.val.Value = script.Parent.val.Value - 1 wait(10) end elseif x.BrickColor == BrickColor.new("Really red") then x.BrickColor = BrickColor.new("Lime green") booleanValue = true while booleanValue do script.Parent.val.Value = script.Parent.val.Value + 1 wait(10) end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Try that.
{ Learning normal Lua and RBX.Lua. } |
|
|
| Report Abuse |
|
|