|
| 29 Jul 2011 06:14 PM |
| How would you check the number of objects inside of another objects being changed, for example, how would I check if the number of players is increased or decreased. (Without check 'NumPlayers' and without using the _OnEntered and _OnLeave functions) |
|
|
| Report Abuse |
|
|
5943539
|
  |
| Joined: 05 Jan 2010 |
| Total Posts: 810 |
|
|
| 29 Jul 2011 06:17 PM |
| PlayerAdded and PlayerRemoving. They're events in the players service. |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2011 06:30 PM |
| I said without using those functions, I'm just using Players as an example, I'll apply the answer to my problem. |
|
|
| Report Abuse |
|
|
RawrBot
|
  |
| Joined: 22 Aug 2008 |
| Total Posts: 832 |
|
|
| 29 Jul 2011 06:37 PM |
If you want the number of stuff inside a Model:
(a model with 5 bricks) modelstuff = Model:GetChildren()
print(#modelstuff)
>5 |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2011 06:38 PM |
| ... No, that's not what I want at all, please read my post carefully. |
|
|
| Report Abuse |
|
|
RawrBot
|
  |
| Joined: 22 Aug 2008 |
| Total Posts: 832 |
|
|
| 29 Jul 2011 06:43 PM |
object.Changed:connect(
--find the number of objects inside it
) |
|
|
| Report Abuse |
|
|
Cliff86
|
  |
| Joined: 01 Mar 2008 |
| Total Posts: 216 |
|
|
| 29 Jul 2011 06:51 PM |
i = game.model:getChildren() m = Instance.new("Hint", workspace) print("Hello World!")
num = #i
function getnum() i = game.model:getChildren() newnum = #i dif = math.abs (newnum - num) if newnum > num then print(dif .. " objects were added to model") elseif newnum < num then print(dif .. " objects were removed from model") end num = newnum end
workspace.model.DescendantAdded:connect(getnum) workspace.model.DescendantRemoving:connect(delay(1,getnum))
|
|
|
| Report Abuse |
|
|
RawrBot
|
  |
| Joined: 22 Aug 2008 |
| Total Posts: 832 |
|
|
| 29 Jul 2011 06:53 PM |
modelstuff = Model:GetChildren()
Model.Changed:connect(function() newmodelstuff = Model:GetChildren()
if #newmodelstuff > #modelstuff then print("Increased") else print("Not increased") end
end) |
|
|
| Report Abuse |
|
|
RawrBot
|
  |
| Joined: 22 Aug 2008 |
| Total Posts: 832 |
|
| |
|