micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 02:09 AM |
local red = 0 local brown = 0 for i,v in pairs(game.Players:GetChildren()) do if v.Character then local torso = v.Character:FindFirstChild("Torso") if torso ~= nil then print((torso.Position-Base.Position).magnitude) if (torso.Position-Base.Position).magnitude <= Distance then if v.TeamColor == "Bright red" then red = red+1 elseif v.TeamColor == "Brown" then brown = brown+1 end end end end end
Whenever I try to print Red and Brown it says 0,0 and won't add. Help? |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 02:14 AM |
| The Distance is auto set to 15 and Base is a part in workspace. |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2015 02:22 AM |
1 for i,v in pairs(game.Players:GetChildren()) do 2 if v.Character then 3 if torso ~= nil then 4 if (torso.Position-Base.Position).magnitude <= Distance then 5 if v.TeamColor == "Bright red" then
1 Are there sufficient players? 2 Is there a character to get? (probably yes.) 3 Is there a torso in the character? 4 Are you sure distance is > 0 and < the area you wont be able to reach 5 Is there a player with Player.TeamColor that == "Bright red" or the other one? |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 02:28 AM |
| It's Torso not torso right? |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 02:30 AM |
1-5
Yes this gets Players, Yes this gets the player property Character, Yes this gets its Torso, Yes I want it less than so to check if your near, Yes the TeamColor is correct! |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 02:40 AM |
| Just realized that is so inefficient..... I'll go over it again, still though anyone see the problem? ChiefDelts won't help meh because he dislikes M3 lol. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
| |
|
|
| 15 Mar 2015 03:02 AM |
local red = 0 local brown = 0 for i,v in pairs(game.Players:GetChildren()) do
Confuses me.
This should be in an event. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 03:04 AM |
It is inside a function, which I call later.
By the way this is an excerpt... |
|
|
| Report Abuse |
|
|
| |
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 03:06 AM |
function bla() --Insert Code Above end
bla() |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2015 03:07 AM |
| This runs once the server started. Therefore nothing is to gather from :GetPlayers() |
|
|
| Report Abuse |
|
|
Fragility
|
  |
| Joined: 12 Mar 2011 |
| Total Posts: 483 |
|
|
| 15 Mar 2015 03:08 AM |
local red = 0 local brown = 0 for i,v in pairs(game.Players:GetChildren()) do if v.Character then local torso = v.Character:FindFirstChild("Torso") if torso ~= nil then print((torso.Position-Base.Position).magnitude) if (torso.Position-Base.Position).magnitude <= Distance then if v.TeamColor == BrickColor.new("Bright red") then red = red+1 elseif v.TeamColor == BrickColor.new("Brown") then brown = brown+1 end end end end end |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 03:08 AM |
No... I use a while wait(1) do end also.
Or I can use wait(1) blah end at the end of the function. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 15 Mar 2015 03:10 AM |
I feel stupid know, thanks it is so late and I can't barely think. Small things such as Brick.new lol.
Anyway thanks! |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2015 03:32 AM |
I totally overlooked that.
Same here. |
|
|
| Report Abuse |
|
|