|
| 22 Oct 2010 03:47 PM |
This is part of a script of mine. Some things you should know:
gameChoices = {1, 2, 3} pickGame = gameChoices[math.random(1, #gameChoices)]
I want pickGame to keep happening until it no longer equals a value in the script, called ChoiceValue. This is what I have so far, but it's not working:
if pickGame == script.ChoiceValue.Value then repeat pickGame wait() until pickGame ~= script.ChoiceValue.Value end
Output only says Workspace.GameScript:33: '=' expected near 'wait' Line 33 is the "wait()". Any help is gladly apreciated. |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 03:48 PM |
if pickGame == script.ChoiceValue.Value then repeat pickGame() wait() until pickGame ~= script.ChoiceValue.Value end |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 03:53 PM |
Nice try.
Workspace.GameScript:32: attempt to call global 'pickGame' (a number value) 32 is "pickGame()" |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 03:56 PM |
| See, pickGame is not a function, it's a variable. |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 03:57 PM |
pickGame = gameChoices[math.random(1, #gameChoices)] if pickGame == script.ChoiceValue.Value then repeat pickGame = gameChoices[math.random(1, #gameChoices)] wait() until pickGame ~= script.ChoiceValue.Value end
|
|
|
| Report Abuse |
|
|
chris1989
|
  |
| Joined: 30 Nov 2007 |
| Total Posts: 2520 |
|
|
| 22 Oct 2010 03:58 PM |
gameChoices = {1, 2, 3}
function pick() pickGame = gameChoices[math.random(1, #gameChoices)] return pickGame end
I want pickGame to keep happening until it no longer equals a value in the script, called ChoiceValue. This is what I have so far, but it's not working:
if pick() == script.ChoiceValue.Value then repeat pick() wait() until pick() ~= script.ChoiceValue.Value end |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 03:59 PM |
| That won't work as intended. The three different calls of pick() may all return different values. |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 04:01 PM |
@Fungal: That's actually the first thing I tried.
@chris: I'll try it. |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 04:01 PM |
@Fungal: Okay, nevermind about trying chris's then... |
|
|
| Report Abuse |
|
|
chris1989
|
  |
| Joined: 30 Nov 2007 |
| Total Posts: 2520 |
|
|
| 22 Oct 2010 04:01 PM |
gameChoices = {1, 2, 3}
function pick() pickGame = gameChoices[math.random(1, #gameChoices)] return pickGame end
pick()
if pickGame == script.ChoiceValue.Value then repeat pick() wait() until pickGame ~= script.ChoiceValue.Value end |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2010 04:12 PM |
@chris: Thanks! It works perfectly. |
|
|
| Report Abuse |
|
|