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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
|
| 12 Apr 2015 01:22 AM |
| Will that detect hats too? |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 12 Apr 2015 04:40 PM |
...you're not calling it. lol
-=Robo=- |
|
|
| Report Abuse |
|
|