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: Visitors getting on the allies team?

Previous Thread :: Next Thread 
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 02:53 PM
I have a Raid GUI Script, and it works fine, except for in my place, I have 4 teams.

Raiders, Allies, Visitors, and Team Domino.

The issue is, I can't figure out how to make the Visitors on the Raiders team without removing the team. Lots of visitors visit the fort, and they go on the allies team in the GUI, which makes the GUI say that a raid is going on.

Here is the part that detirmines which teams are on the Allies, and Raiders:

ally = {"Team Domino","Allies"}
enemy = "Raiders"

The only issue is, when I try and say this:
ally = {"Team Domino","Allies"}
enemy = {"Raiders", "Visitors"}

The script breaks.
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 02:58 PM
This is pertaining to the logic of your whole script, you can't just change a string into a table and expect everythign to work the same.
Post the script in its entirety.
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 02:59 PM
*everything, excuse me.
Oh, laggy Ubuntu.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 02:59 PM
ally = {"Team Domino","Allies"}
enemy = "Raiders"

while true do
local plrs = game.Players:getPlayers()
local allies = 0
local enemies = 0
if #plrs >= 1 then
for i = 1, #plrs do
if plrs[i].TeamColor == game.Teams[enemy].TeamColor then
enemies = enemies + 1
elseif plrs[i].TeamColor == game.Teams[ally[1]].TeamColor or game.Teams[ally[2]].TeamColor or game.Teams[ally[3]].TeamColor then
allies = allies + 1
end
end
end

if allies >= 6 and enemies >= 3 then
print("Raid!")
script.Parent.RaidStatus.Text = "Raid"
script.Parent.RaidStatus.TextColor3 = Color3.new(255/255,0,0)
else
script.Parent.RaidStatus.Text = "No Raid"
script.Parent.RaidStatus.TextColor3 = Color3.new(0,255/255,0)
end
script.Parent.Allies.Text = "Allies: "..allies
script.Parent.Raiders.Text = "Raiders: "..enemies
allies = 0
enemies = 0
wait(.5)
end
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:06 PM
Bump
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 03:11 PM
The code "game.Teams[enemy]" is the fragment that is breaking it.
Since enemy is changed into a table, it will return the game data of the table.
Therefore you must run a pairs loop through the table of "enemy," but a simpler way would be to add an "OR" statement into the if.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:15 PM
Right... I'm just beginning to get into this kind of scripting, so, can you put that in simpler terms? I'm bad with pairs loops.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:17 PM
OHHHHHHH!!!!!!! Okay!

So like this?

game.Teams[enemy[1]].TeamColor or game.Teams[enemy[2]].TeamColor?

then I could do
enemy = {"Raiders", "Visitors"}?
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 03:19 PM
Basically, you need to do this:
for x,y in pairs(enemy) do
if Game.Teams[y] --- ... continue the rest here
--do
end
end
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 03:20 PM
Yes, that's exactly it. The way I just posted is less efficient, but you have it. You have nice comprehension skills.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:22 PM
For the GUI, could I possibly make another TextLabel, and do this?

if #plrs >= 1 then
for i = 1, #plrs do
if plrs[i].TeamColor == game.Teams[enemy[1].TeamColor or game.Teams[enemy[2]].TeamColor then
enemies = enemies + 1
elseif plrs[i].TeamColor == game.Teams[ally[1]].TeamColor or game.Teams[ally[2]].TeamColor then
allies = allies + 1
elseif plrs[i].TeamColor == game.Teams[Visitors[1]].TeamColor then
visitor = visitor + 1

end
end
end

and at the top, with the variables have this?

ally = {"Team Domino","Allies"}
enemy = "Raiders"
visitor = "Visitors"?
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:25 PM
Also, for the line that identifies how many players are needed for a raid, would I just leave it the same, because Visitors can't raid, or would that break the script?

if allies >= 6 and enemies >= 3 then?
Report Abuse
cygorx is not online. cygorx
Joined: 09 Nov 2012
Total Posts: 668
11 Nov 2012 03:27 PM
Yes, that works, no problem.
Everything should be fine now.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 03:30 PM
Super.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 07:58 PM
Okay... The Raid Status GUI is busted... Mind helping again?
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 08:02 PM
Wait. Nevermind. I forgot to change:

script.Parent.Allies.Text = "Allies: "..allies
script.Parent.Raiders.Text = "Raiders: "..enemies
into;

script.Parent.Allies.Text = "Allies: "..allies
script.Parent.Raiders.Text = "Raiders: "..enemies
script.Parent.Visitors.Text = "Visitors: "..visitors
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 08:26 PM
Wait, it's still broken.
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 09:26 PM
Here are the updates I made to the script. Whats up?

ally = {"Team Domino","Allies"}
enemy = "Raiders"
visitor = "Visitors"

while true do
local plrs = game.Players:getPlayers()
local allies = 0
local enemies = 0
if #plrs >= 1 then
for i = 1, #plrs do
if plrs[i].TeamColor == game.Teams[enemy]].TeamColor then
enemies = enemies + 1
elseif plrs[i].TeamColor == game.Teams[ally[1]].TeamColor or game.Teams[ally[2]].TeamColor or game.Teams[ally[3]].TeamColor or
allies = allies + 1
elseif plrs[i].TeamColor == game.Teams[visitor[1]].TeamColor then
visitor = visitor + 1


end
end
end

if allies >= 6 and enemies >= 3 then
print("Raid!")
script.Parent.RaidStatus.Text = "Raid"
script.Parent.RaidStatus.TextColor3 = Color3.new(255/255,0,0)
else
script.Parent.RaidStatus.Text = "No Raid"
script.Parent.RaidStatus.TextColor3 = Color3.new(0,255/255,0)
end
script.Parent.Allies.Text = "Allies: "..allies
script.Parent.Raiders.Text = "Raiders: "..enemies
script.Parent.Raiders.Text = "Visitors: "..visitors
allies = 0
enemies = 0
visitprs = 0
wait(.5)
end


But it still won't work?
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
11 Nov 2012 09:39 PM
game.Teams[enemy]]

Should:

game.Teams[enemy]
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
11 Nov 2012 09:41 PM
visitor = "Visitor"

visitor = visitor + 1

??

and

visitprs = 0


?????
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
11 Nov 2012 09:59 PM
Okay. I got the first part, but could you please be more thorough and specific on the second one?
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
12 Nov 2012 03:47 PM
Hullo?
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
12 Nov 2012 04:08 PM
Bump...
Report Abuse
Wierdo1337 is not online. Wierdo1337
Joined: 27 Jun 2012
Total Posts: 3814
12 Nov 2012 04:35 PM
Help?
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