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: Magnitude and Issue

Previous Thread :: Next Thread 
micke3212 is not online. 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 is not online. 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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
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 is not online. micke3212
Joined: 24 Nov 2009
Total Posts: 3000
15 Mar 2015 02:28 AM
It's Torso not torso right?
Report Abuse
micke3212 is not online. 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 is not online. 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 is not online. micke3212
Joined: 24 Nov 2009
Total Posts: 3000
15 Mar 2015 02:54 AM
Help please.
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
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 is not online. 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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
15 Mar 2015 03:05 AM
There is your problem.
Report Abuse
micke3212 is not online. micke3212
Joined: 24 Nov 2009
Total Posts: 3000
15 Mar 2015 03:06 AM
function bla()
--Insert Code Above
end

bla()
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
15 Mar 2015 03:07 AM
This runs once the server started. Therefore nothing is to gather from :GetPlayers()
Report Abuse
Fragility is not online. 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 is not online. 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 is not online. 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
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
15 Mar 2015 03:32 AM
I totally overlooked that.

Same here.
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