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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 09 May 2015 |
| Total Posts: 13095 |
|
|
| 25 Jul 2017 12:22 AM |
oh wait ur right
maybe u have FE enabled |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 25 Jul 2017 12:22 AM |
| Try DescendantAdded maybe? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 25 Jul 2017 12:26 AM |
| ignore me being dumb lol, system what you said should work |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Jul 2017 12:31 AM |
FE shouldn't effect something like this.
Did you try DescendantAdded? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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
|
  |
| 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 |
|
|
|
| 25 Jul 2017 12:46 AM |
| Was this inside of the startpack or something? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Jul 2017 12:53 AM |
| Oh I get why it's not firing then, that makes a lot of sense |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2017 05:41 AM |
You need to define the player first...
Example:
if player.Character then
-- stuff |
|
|
| Report Abuse |
|
|