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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Getting the mass of the ENTIRE player?

Previous Thread :: Next Thread 
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:04 AM
Is this possible? And If so.. How? I need to include hats, bodyparts, exc
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:07 AM
really simplistic
roll through with a recursive check, if parts are "parts"
if they are, get their mass
add the results
return the total

-=Robo=-
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:09 AM
How do i check if the parts are "part"s? I know how to run through the players, but how do i do that?
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:15 AM
local function GetMass(PartModel)
local function a(m)
local massiveass = 0
for _, obj in pairs(m:GetChildren()) do
a(obj)
if obj:IsA("BasePart") then
massiveass = (massiveass + obj:GetMass())
end
end
return massiveass
end
return a(PartModel)
end

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:16 AM
actually there's a pretty blatant problem with that, i'm really tired, sorry lol

local function GetMass(PartModel)
local massiveass = 0
local function a(m)
for _, obj in pairs(m:GetChildren()) do
a(obj)
if obj:IsA("BasePart") then
massiveass = (massiveass + obj:GetMass())
end
end
end
a(PartModel)
return massiveass
end

-=Robo=-
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:22 AM
Will that detect hats too?
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:24 AM
yes, it's recursing, so i'm assuming it would pick up the hat's handle.

-=Robo=-
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:25 AM
Awesome! Thanks so much!
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:27 AM
No problem.
You might not want to call it immediately, though. If the player's appearance hasn't loaded, I can't guarantee it will grab an accurate mass(the hats might not have loaded)

-=Robo=-
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:32 AM
Yea.. It grabs it after 2 seconds.. But my problem is its not picking up the mass for the hats.. and when i take the hats off, its not changing the mass. heres my code:

Mass = 0

for _, obj in pairs(Character:GetChildren()) do
if obj:IsA("BasePart") then
Mass = Mass + obj:GetMass()
end
end
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 01:36 AM
You're not recursing.

A recursion, as I'd put it, is a continuous loop through an array(as far as Lua is concerned), just have a local function and call it in itself with every individual object, getting the children of every child, as I did.

-=Robo=-
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
12 Apr 2015 01:44 AM
It Prints Nil whenever i print it.. here is the code.. This may be really obvious but idk.

function GetMass(PartModel)
Mass = 0
local function a(m)
for _, obj in pairs(m:GetChildren()) do
a(obj)
if obj:IsA("BasePart") then
Mass = (Mass + obj:GetMass())
end
end
end
a(PartModel)
return Mass
end

Gravity.force = Vector3.new(0, 196.2, 0) * Vector3.new(0, Mass, 0)
print(Mass)

Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
12 Apr 2015 04:40 PM
...you're not calling it. lol

-=Robo=-
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