generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Keep running until it doesn't equal.

Previous Thread :: Next Thread 
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
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
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
22 Oct 2010 03:48 PM
if pickGame == script.ChoiceValue.Value then
repeat
pickGame()
wait()
until pickGame ~= script.ChoiceValue.Value
end
Report Abuse
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
22 Oct 2010 03:53 PM
Nice try.

Workspace.GameScript:32: attempt to call global 'pickGame' (a number value)
32 is "pickGame()"
Report Abuse
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
22 Oct 2010 03:56 PM
See, pickGame is not a function, it's a variable.
Report Abuse
Fungalmungal is not online. Fungalmungal
Joined: 18 Oct 2008
Total Posts: 2519
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 is not online. 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
Fungalmungal is not online. Fungalmungal
Joined: 18 Oct 2008
Total Posts: 2519
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
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
22 Oct 2010 04:01 PM
@Fungal:
That's actually the first thing I tried.

@chris:
I'll try it.
Report Abuse
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
22 Oct 2010 04:01 PM
@Fungal:
Okay, nevermind about trying chris's then...
Report Abuse
chris1989 is not online. 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
ChaosStar95 is not online. ChaosStar95
Joined: 19 Feb 2009
Total Posts: 5943
22 Oct 2010 04:12 PM
@chris:
Thanks! It works perfectly.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image