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: Error in Script for Rock-Paper-Scissors Game?

Previous Thread :: Next Thread 
ShagFace is not online. ShagFace
Joined: 22 Aug 2011
Total Posts: 3474
28 Sep 2014 06:24 PM
Alright, so I created a script for a RPS game, however the script keeps telling me there's a "Syntax Error: Unexpected token else"


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}
compare(else if (choice1 === "rock")
if (choice2 == "scissors")
return "Paper wins";
}
};



If anyone could help me, I'd seriously appreciate it
Thanks
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Sep 2014 06:25 PM
you should go to scripters, most people here specialize in RBX lua not java or w/e this is
Report Abuse
ShagFace is not online. ShagFace
Joined: 22 Aug 2011
Total Posts: 3474
28 Sep 2014 06:26 PM
Ok, thank you
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
28 Sep 2014 06:27 PM
What has Lua done to deserve this pain.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
28 Sep 2014 06:29 PM
^ lol this is javascript

@op

try:
} else if (computerChoice > 0.67) {

instead of } else {
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
28 Sep 2014 06:41 PM
Ignore that post there ^^^^ op, listen to my post on your thread in scripters.
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