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: Why does this script not work!?

Previous Thread :: Next Thread 
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:22 PM
while true do
script.Parent.Value = math.random(1,2)

getTeamCount = function(TeamColor)
local count = 0
for _,Player in next, game:GetService("Players"):GetChildren() do
count = count + (Player.TeamColor==TeamColor and 1 or 0)
end
end


if script.Parent.Value == 1 then
wait(1)
game.Lighting.Search:clone().Parent = game.Workspace
game.Lighting.Map1:clone().Parent = game.Workspace
if getTeamCount(BrickColor.new("Lime green"))< 2 then
wait(8)
game.Workspace.Map1:remove()
game.Workspace.Search:remove()
wait(5)
end
elseif script.Parent.Value == 2 then
wait(1)
game.Lighting.Search:clone().Parent = game.Workspace
game.Lighting.Map2:clone().Parent = game.Workspace
if getTeamCount(BrickColor.new("Lime green"))< 2 then
wait(5)
game.Workspace.Map2:remove()
game.Workspace.Search:remove()
wait(5)
end
end
end


it doesn't delete that map if there are less than 2 people on "Lime green"..
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:43 PM
grr I'm frustrated
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
05 Mar 2014 05:44 PM
Do you have any errors?

~ Usering ~
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:47 PM
26: attempt to compare nil with number
Report Abuse
ShagFace is not online. ShagFace
Joined: 22 Aug 2011
Total Posts: 3474
05 Mar 2014 05:47 PM
Is the model named "Map1"?

Just re-check the specific model's name, as this is a common error for most scripters
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:48 PM
Yes; it does clone the map, it just doesn't remove it..
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
05 Mar 2014 05:51 PM
Because you're comparing nil with a number: "if getTeamCount(BrickColor.new("Lime green"))< 2 then"

You never returned count, so the function returns nil.

getTeamCount = function(TeamColor)
count = 0
for _,Player in next, game:GetService("Players"):GetChildren() do
count = count + (Player.TeamColor==TeamColor and 1 or 0)
end
return count
end

~ Usering ~
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:55 PM
Awesome, that worked! Thanks Usering!
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:56 PM
Also, will this keep checking the number of players on the team until it finds that there is less than 2 players on the team, or does it only check once?
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
05 Mar 2014 05:57 PM
It will only check once since it's in that same loop.

~ Usering ~
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 05:59 PM
How can I make it so that it keeps checking?
Report Abuse
Usering is not online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
05 Mar 2014 06:03 PM
This isn't the most efficient way of doing so, but:

Put that function into a another script and have it constantly checking for the amount of players in the team.
Have a IntValue in workspace where that script puts the number of players on the team.
In your while loop in your script above, have a .Changed event so when the team count changes, you can check it's value and if it is less than the amount you want, then it does it's thing.

~ Usering ~
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 06:06 PM
not too experienced in scripting, not sure how to do that =l
Report Abuse
Whipitz is not online. Whipitz
Joined: 10 Oct 2008
Total Posts: 1364
05 Mar 2014 06:14 PM
=/
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