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 » Scripters
Home Search
 

Re: why isnt this working right?

Previous Thread :: Next Thread 
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 09:52 AM
everything works fine, except that if game.Workspace.Mode.Value == 3 it will only bring 1 player.

for i, player in ipairs(game.Players:GetChildren()) do
if player.Character then
if game.Workspace.Mode.Value ~= 3 then
player.TeamColor = BrickColor.new("Cyan")
player.Character:BreakJoints()
elseif game.Workspace.Mode.Value == 3 then
game.Workspace.newround.Value = 15
local red = Instance.new("Team",game.Teams)
red.TeamColor = BrickColor.new("Bright red")
red.Name = "Red Team"
red.AutoAssignable = false
local blue = Instance.new("Team",game.Teams)
blue.TeamColor = BrickColor.new("Bright blue")
blue.Name = "Blue Team"
blue.AutoAssignable = false
if game.Workspace.redteam.Value == game.Workspace.blueteam.Value then
game.Workspace.random.Value = math.random(1,2)
wait(.01)
if game.Workspace.random.Value == 1 then
player.TeamColor = BrickColor.new("Bright red")
game.Workspace.redteam.Value = game.Workspace.redteam.Value +1
player.Character:BreakJoints()
elseif game.Workspace.random.Value == 2 then
player.TeamColor = BrickColor.new("Bright blue")
game.Workspace.blueteam.Value = game.Workspace.blueteam.Value +1
player.Character:BreakJoints()
if game.Workspace.redteam.Value >= game.Workspace.blueteam.Value then
player.TeamColor = BrickColor.new("Bright red")
player.Character:BreakJoints()
game.Workspace.redteam.Value = game.Workspace.redteam.Value +1
elseif game.Workspace.redteam.Value <= game.Workspace.blueteam.Value then
player.TeamColor = BrickColor.new("Bright blue")
game.Workspace.blueteam.Value = game.Workspace.blueteam.Value +1
player.Character:BreakJoints()
end
end

end
end
end
end


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 10:24 AM
bump


Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
14 Jul 2016 10:24 AM
Why are you not using variables...
Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:05 PM
is that why it doesnt work right?


Report Abuse
MasterXertz is not online. MasterXertz
Joined: 04 Jun 2010
Total Posts: 1499
14 Jul 2016 03:06 PM
^No... but it would make it 1000x easier for us to fix if you used variables. It would also organize it and shorten it.


Star Wars Fans: https://www.roblox.com/games/345312845/-
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
14 Jul 2016 03:09 PM
May i ask what is this suppozt to be,cuz i belive i could make it way shoreter ,even whitout variables,..?
Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:12 PM
if Mode doesnt equal 3 then all players become team cyan and it kills them, if it does = 3 then it creates the teams blue and red and splits all the players into even teams


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:27 PM
i just found on the wiki "rebalanceteams()", but it says its deprecated, is there anything similar to that which isnt deprecated, because thats pretty much what im trying to do except with 2 teams.


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:39 PM
bump


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:47 PM
bump


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 03:58 PM
b


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 04:05 PM
someone please help, im trying to make balanced teams. it works but only for 1 player, and then continues the main game script, even though in:

for i, player in ipairs(game.Players:GetChildren()) do
if player.Character then

it is supposed to do the stuff for all players




Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 04:52 PM
bump


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Jul 2016 05:02 PM
for i,v in next, game.Players:GetPlayers() do
if i%2 == 0 then
v.Team = game.Teams['Red']
else
v.Team = game.Teams['Blue']
end
end


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 05:04 PM
thanks so much, going to try it


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 05:14 PM
everything works, thanks so much time


Report Abuse
TheeDeathCaster is not online. TheeDeathCaster
Joined: 19 Jun 2011
Total Posts: 1191
14 Jul 2016 05:18 PM
@OP I don't use ipairs because it stops when it hits a nil iteration; have you tried using pairs?


Now, look up in the upper-right corner of your screen, that red box there: that's the door.
Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 05:21 PM
i dont really know how to use pairs, its confusing. the closest thing i know how to do is for loops. i got ipairs from the wiki for teleporting players. i just changed it a bit to try and get it to work for me


Report Abuse
TheeDeathCaster is not online. TheeDeathCaster
Joined: 19 Jun 2011
Total Posts: 1191
14 Jul 2016 05:27 PM
@OP They're both used (almost) exactly the same; as for example, in this code, you can just replace ipairs w/ pairs:

for i, v in pairs(tbl) do

for i, v in ipairs(tbl) do

Imo, there really isn't too much of a difference between the two, except that ipairs stops the iteration when it hits a nil iteration (in the table):

local tbl = {
1,
2,
3,
nil,
5,
6
}

for i, v in ipairs(tbl) do
print(v) -- Stops at 3
end

However, pairs will still proceed to go through the table, even though it hit a nil iteration; it appears to just skip the nil iteration, not return it, and proceed onto the next iteration of the table:

local tbl = {
1,
nil,
3,
nil,
5,
6
}

for i, v in pairs(tbl) do
print(v) -- 1, 3, 5, 6
end


Now, look up in the upper-right corner of your screen, that red box there: that's the door.
Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 05:30 PM
oh, thanks for explaining the difference, i didnt understand it.


Report Abuse
TheeDeathCaster is not online. TheeDeathCaster
Joined: 19 Jun 2011
Total Posts: 1191
14 Jul 2016 05:34 PM
@OP Np; you can continue to use ipairs if you want, I was just letting you know (and annoyingly informing) it stops the iteration when it hits nil. :)


Now, look up in the upper-right corner of your screen, that red box there: that's the door.
Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
14 Jul 2016 05:36 PM
ok thanks


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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