IWin2
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 79 |
|
|
| 13 Jul 2012 10:40 PM |
Hey guys, I'm currently writing a script for my Search and Destroy gamemode and was wondering if the below script would work. Thanks!
local redDets = workspace.Detonations.redDet return redDets.Value local blueDets = workspace.Detonations.blueDet return blueDets.Value local redDefs = workspace.Defuses.redDef return redDef.Value local blueDefs = workspace.Defuses.blueDef return blueDef.Value
if (not gameEnd) then if (redDet = 1) then _G.endGame(game.Teams.Red, "The red team wins, the objective has been destroyed!") elseif (blueDet = 1) then _G.endGame(game.Teams.Blue, "The blue team wins, the objective has been destroyed!") elseif (redDef = 1) then _G.endGame(game.Teams.Red, "Bomb defused, the red team wins!") elseif (blueDef = 1) then _G.endGame(game.Teams.Blue, "Bomb defused, the blue team wins!") elseif (redPlayers <= 0) and (bluePlayers > 0) then _G.endGame(game.Teams.Blue, "Red players eliminated! The Blue team wins!") gameEnd = true elseif (bluePlayers <= 0) and (redPlayers > 0) then _G.endGame(game.Teams.Red, "Blue players eliminated! The Red team wins!") gameEnd = true else if redPlayers.Value = bluePlayers.Value _G.endGame(nil, "Time's up! It's a draw! Both teams had "..redPlayers.." players left!") if redPlayers.Value > bluePlayers.Value _G.endGame(nil, "Time's up! The red team wins with "..redPlayers.." left!" if bluePlayers.Value > redPlayers.Value _G.endGame(nil, "Time's up! The blue team wins with "..bluePlayers.." left!" end end end) |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2012 10:41 PM |
| Hmmmmmmmmmmmmmmmmmmmmmmmmmmmm... |
|
|
| Report Abuse |
|
|
ThatThar
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 794 |
|
|
| 13 Jul 2012 10:45 PM |
if (not gameEnd) then if (redDet == 1) then _G.endGame(game.Teams.Red, "The red team wins, the objective has been destroyed!") elseif (blueDet == 1) then _G.endGame(game.Teams.Blue, "The blue team wins, the objective has been destroyed!") elseif (redDef == 1) then _G.endGame(game.Teams.Red, "Bomb defused, the red team wins!") elseif (blueDef == 1) then _G.endGame(game.Teams.Blue, "Bomb defused, the blue team wins!") elseif (redPlayers <= 0) and (bluePlayers > 0) then _G.endGame(game.Teams.Blue, "Red players eliminated! The Blue team wins!") gameEnd = true elseif (bluePlayers <= 0) and (redPlayers >= 0) then _G.endGame(game.Teams.Red, "Blue players eliminated! The Red team wins!") gameEnd = true else if redPlayers.Value == bluePlayers.Value _G.endGame(nil, "Time's up! It's a draw! Both teams had "..redPlayers.." players left!") if redPlayers.Value >= bluePlayers.Value _G.endGame(nil, "Time's up! The red team wins with "..redPlayers.." left!" if bluePlayers.Value >= redPlayers.Value _G.endGame(nil, "Time's up! The blue team wins with "..bluePlayers.." left!" end end end)
If it's comparing, it needs 2 '='s or a '=' after the '<' or '>'. |
|
|
| Report Abuse |
|
|
ThatThar
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 794 |
|
|
| 13 Jul 2012 10:47 PM |
| Otherwise, it'll error "'then' expected near '=' or some form of that, depending on whether it was a <, >, or = you didn't add another = to. |
|
|
| Report Abuse |
|
|
IWin2
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 79 |
|
|
| 13 Jul 2012 10:53 PM |
Oh, okay thanks.
local redDets = workspace.Detonations.redDet return redDet.Value local blueDets = workspace.Detonations.blueDet return blueDet.Value local redDefs = workspace.Defuses.redDef return redDef.Value local blueDefs = workspace.Defuses.blueDef return blueDef.Value
Also, would the above work correctly so long as redDet, blueDet, redDef and blueDef are string values? |
|
|
| Report Abuse |
|
|
ThatThar
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 794 |
|
|
| 13 Jul 2012 10:57 PM |
| If those are value objects, then it needs to be redDets.Value, blueDets.Value, etc. |
|
|
| Report Abuse |
|
|
IWin2
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 79 |
|
|
| 13 Jul 2012 11:02 PM |
| I'm not sure what you mean if they are value objects, redDet, blueDet etc.. are the names of the string values. |
|
|
| Report Abuse |
|
|
ThatThar
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 794 |
|
|
| 13 Jul 2012 11:10 PM |
| Are they in the Workspace? |
|
|
| Report Abuse |
|
|
IWin2
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 79 |
|
|
| 13 Jul 2012 11:22 PM |
redDet and blueDet are In a group named Detonations, this group is in workspace. redDef and blueDef are In a group named Defuses, this group is in workspace. |
|
|
| Report Abuse |
|
|
ThatThar
|
  |
| Joined: 09 Jul 2012 |
| Total Posts: 794 |
|
| |
|
IWin2
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 79 |
|
|
| 13 Jul 2012 11:26 PM |
| Ok, thanks alot for the help :) Now I can continue working on the rest of the game mode :D |
|
|
| Report Abuse |
|
|