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: Would this work?

Previous Thread :: Next Thread 
IWin2 is not online. 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
ThrashSurfFlapjack is not online. ThrashSurfFlapjack
Joined: 20 Feb 2012
Total Posts: 164
13 Jul 2012 10:41 PM
Hmmmmmmmmmmmmmmmmmmmmmmmmmmmm...
Report Abuse
ThatThar is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. ThatThar
Joined: 09 Jul 2012
Total Posts: 794
13 Jul 2012 11:10 PM
Are they in the Workspace?
Report Abuse
IWin2 is not online. 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 is not online. ThatThar
Joined: 09 Jul 2012
Total Posts: 794
13 Jul 2012 11:24 PM
It should work then.
Report Abuse
IWin2 is not online. 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
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