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: ChildAdded not firing for backpack

Previous Thread :: Next Thread 
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:00 AM
For some reason I can't get backpack to fire ChildAdded

game.Players.LocalPlayer.Backpack.ChildAdded:connect(function(obj)
print(obj)
end)

idk why, work arounds?
Report Abuse
Arkitek is online. Arkitek
Joined: 09 May 2015
Total Posts: 13095
25 Jul 2017 12:11 AM
it says on roblox wiki that child added fires when a child is added to the object

i dont think a backpack is an object but i could be totally wrong so



my 2 cents


Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:15 AM
I mean on the wiki it says backpack inherits the "Instance Class" which has ChildAdded or wahtever. I mean it seems like it doesn't work so lol
Report Abuse
Arkitek is online. Arkitek
Joined: 09 May 2015
Total Posts: 13095
25 Jul 2017 12:22 AM
oh wait ur right


maybe u have FE enabled
Report Abuse
engeryman567 is not online. engeryman567
Joined: 05 Jun 2011
Total Posts: 52
25 Jul 2017 12:22 AM
Is it a LocalScript? I did a bit of research, and it turns out game.Players.LocalPlayer.Backpack is used for LocalScripts, if you wanted to use a regular script then you'd do game.Players.PlayerName.Backpack
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:22 AM
Try DescendantAdded maybe?
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:23 AM
@engery well, if he's using LocalPlayer, I'm sure he knows to use a Local Script lol
Report Abuse
Arkitek is online. Arkitek
Joined: 09 May 2015
Total Posts: 13095
25 Jul 2017 12:26 AM
or maybe the script runs before any child is added to the backpack
Report Abuse
engeryman567 is not online. engeryman567
Joined: 05 Jun 2011
Total Posts: 52
25 Jul 2017 12:26 AM
ignore me being dumb lol, system what you said should work
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:30 AM
Yeah it's in a local script, FE is enabled, and I am "equiping" and "unequiping" the tool so it ends up in my backpack.

Also tried parenting it with commands

Also tried dragging and dropping it in studio.
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:31 AM
FE shouldn't effect something like this.

Did you try DescendantAdded?
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:32 AM
Huh I tried it in a small script and it worked.
Guess something with my larger script.
Ignore this post for now. I will return.
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:32 AM
I did try descendant added in my larger script.
It's something else. I will report back once I find it.

Sorry for wasting your guys' time lol
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:32 AM
I mean, just to check, I guess you could turn off FE and test it real quick
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:33 AM
O
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:39 AM
I'm still stumped

print"boop"
plr.Backpack.ChildAdded:connect(function(obj)
print"ah"
if obj:IsA'Tool' then
local inTable = false
local i = 0
while (not inTable) do
i = i + 1
inTable = toolTab[i] == obj
end
if not inTable then
print("New tool "..obj.Name.." added!")
toolTab[#toolTab] = obj
end
end
end)

plr.Backpack.ChildRemoved:connect(function(obj)
wait()
if not obj or (obj:IsA'Tool' and obj.Parent ~= humanoid and obj.Parent ~= nil) then
print("Dropped "..obj.Name)
for i,tool in next, toolTab do
if obj == tool then
table.remove(toolTab,i)
break
end
end
end
end)

plr.CharacterAdded:connect(function(char)
humanoid = char:WaitForChild"Humanoid"
char.ChildAdded:connect(function(obj)
if obj:IsA'Tool' then
print("Added to Humanoid")
end
end)
end)

uh everything is defined don't worry. I get printed out "boop" and "Added to Humanoid" but not "Ah"
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:41 AM
Found the problem

"Once a character dies, the Backpack is removed and a new one created (again populated with the contents of StarterPack and StarterGui)." ~ Wiki


All is resolved.

Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:46 AM
Was this inside of the startpack or something?
Report Abuse
Zawie is not online. Zawie
Joined: 04 Jul 2010
Total Posts: 6338
25 Jul 2017 12:52 AM
no its just that the player is loaded after the local script is ran basically, well
not quite.

What I mean by that is by the time the character has an opportunity to pick up a tool the server ran :LoadCharacter() on him essentially "killing" him
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
25 Jul 2017 12:53 AM
Oh I get why it's not firing then, that makes a lot of sense
Report Abuse
ForceCyber is not online. ForceCyber
Joined: 06 May 2015
Total Posts: 1086
25 Jul 2017 05:41 AM
You need to define the player first...

Example:

if player.Character then

-- stuff
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