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 » Scripting Helpers
Home Search
 

Re: How to use the Changed event with # of children?

Previous Thread :: Next Thread 
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Jun 2013 03:48 PM
Change is a function in my code*
#workspace.children().Changed:connect(Change)

Out put has a problem with the number sign.
print(#workspace.children()) worked for me.

~ The ATR Fishie ~
Report Abuse
getkoed2 is not online. getkoed2
Joined: 11 Apr 2010
Total Posts: 1144
13 Jun 2013 03:50 PM
local v = Instance.new("IntValue", script)
v.Name = "stuff"
v.Value = #workspace:GetChildren()

workspace.ChildAdded:connect(function()
v.Value = #workspace:GetChildren()
end)

v.Changed:connect(function()
print(v.Value)
end)
Report Abuse
EchoReaper is online. EchoReaper
Joined: 14 Oct 2008
Total Posts: 4323
13 Jun 2013 04:37 PM
@get: That will only run when a child is added to the workspace. It won't function for items already in it.

function objChanged(o)
--do stuff you need to here. "o" is the item that changed.
end


for i,v in pairs(workspace:GetChildren()) do
v.Changed:connect(function(objChanged)
end
Report Abuse
EchoReaper is online. EchoReaper
Joined: 14 Oct 2008
Total Posts: 4323
13 Jun 2013 04:39 PM
for i,v in pairs(etc) runs through the items in the workspace where i is the number of the item, and v is the item itself.

v.Changed runs when the v changes and sends v(the object) to function ObjChanged.
Report Abuse
getkoed2 is not online. getkoed2
Joined: 11 Apr 2010
Total Posts: 1144
14 Jun 2013 06:07 AM
@Echo
As soon as something gets in workspace, like a character, it already shows how many children workspace has.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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