|
| 25 Nov 2012 12:51 PM |
local t = game.Workspace.Ticker local f = game.Lighting local w = game.Workspace.Scripts.WColor local x = game.Workspace.Scripts.Weather.Random.Value local n = x
while true do wait(3) x = math.random(1,9) -- If x =1 if x == 1 then do t.Text = "Work 1" print '1' end -- If x =2 if x == 2 then do t.Text = "Work 2" print '2' end -- If x =3 if x == 3 then do t.Text = "Work 3" print '3' end end end end end
I am trying to have every few seconds for a random action to happen, but it keeps giving me one and a bunch of errors. Can someone help me fix this? |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 25 Nov 2012 12:52 PM |
| change x to another variable you didn't use. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:55 PM |
| Yeah, change one of the x variables to something else. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:56 PM |
local t = game.Workspace.Ticker local f = game.Lighting local w = game.Workspace.Scripts.WColor local x = game.Workspace.Scripts.Weather.Random.Value local n = x
while true do wait(3) x = math.random(1,9) -- If x =1 if x == 1 then t.Text = "Work 1" print("1") -- If x =2 elseif x == 2 then t.Text = "Work 2" print("2") -- If x =3 elseif x == 3 then t.Text = "Work 3" print("3") end end end end end |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:56 PM |
remove all the 'do's after the if statements, they aren't wrong but I'm guessing you didn't mean to have them. Also, I think you want to use elseif statements here. Here: local t = game.Workspace.Ticker local f = game.Lighting local w = game.Workspace.Scripts.WColor local x = game.Workspace.Scripts.Weather.Random local n = x
while true do wait(3) x.Value = math.random(1,9) -- If x =1 if x.Value == 1 then t.Text = "Work 1" print '1' elseif x.Value == 2 then t.Text = "Work 2" print '2' elseif x.Value == 3 then t.Text = "Work 3" print '3' end end |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 12:57 PM |
Just so you know you cant have x = game.Workspace.Scripts.Weather.Random and then say x = 10 and expect it to change Weather.Random's value, it only sets your variable 'x' to 10 |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 25 Nov 2012 12:57 PM |
local t = workspace.Ticker local f = game.Lighting local w = workspace.Scripts.WColor local x = workspace.Scripts.Weather.Random.Value
while wait(3) do y = math.random(1,9) -- If x =1 if x == 1 then t.Text = "Work 1" print("1") -- If x =2 elseif y == 2 then t.Text = "Work 2" print("2") -- If x =3 elseif y == 3 then t.Text = "Work 3" print("3") end end |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 25 Nov 2012 12:58 PM |
| If you are really weird and still want to use X inside the loop, use local x. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 01:04 PM |
@nrscsy Your method wouldn't work because a) It has all the problems other than x being called twice b) I think he wants to change the Weather.Random's actual value c) You didn't change the 'if x==' statements to 'if y==' statements. |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 25 Nov 2012 01:06 PM |
I had forggoten one x == change, sorry about that. I don't spot any problems, the script seems fine. He can later on apply y to the weather value, no problem. |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 25 Nov 2012 01:10 PM |
local t = game.Workspace.Ticker local f = game.Lighting local w = game.Workspace.Scripts.WColor local y = game.Workspace.Scripts.Weather.Random.Value local n = y
function msg() local t = Instance.new("Message", workspace) end
while wait(3) do x = math.random(1,9) -- If x =1 if x == 1 then do msg() t.Text = "Work "..x print(x) end -- If x =2 elseif x == 2 then do msg() t.Text = "Work "..x print(x) end -- If x =3 elseif x == 3 then do msg() t.Text = "Work "..x print(x) end end end |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 01:41 PM |
| Thanks, the elseif change made it work. c: |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 02:02 PM |
See, I told you guys that the elseif change would make it work.
http://wiki.roblox.com/index.php/User:ElectricBlaze |
|
|
| Report Abuse |
|
|