Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

ChildAdded script not working?

Asked by
u_g 90
10 years ago

I made a "ChildAdded" script, but it doesn't seem to work. It's supposed to change the text of a Gui in a player when a child is added into the "leaderstats" model. For some reason, it's not working, or even detecting the child being added. I tried a "script.Parent.ChildAdded:connect(function(child)" kind of thing, too, but that doesn't work either. Here's the script:

local function onChildAdded(child)
print("Script has detected a child added")
    script.Parent.Parent.PlayerGui.Notifications.Play.Text = ("1"..child.Name.."added to inventory")
    wait(4)
script.Parent.Parent.PlayerGui.Notifications.Play.Text = " "
end
script.Parent.ChildAdded:connect(onChildAdded)
0
Where is the script in the Instance Hierarchy? duckwit 1404 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago
function onChildAdded(child) --I think you put this in StarterPack I heard that it doesn't work any more so put it in StarterGui.
wait(0.25) --it waits for it to load.
print("Script has detected a child added")
    script.Parent.Parent.PlayerGui.Notifications.Play.Text = ("1"..child.Name.."added to inventory")
    wait(4)
script.Parent.Parent.PlayerGui.Notifications.Play.Text = " "
end
script.Parent.ChildAdded:connect(onChildAdded)

0
Actually, this script is cloned into every single "leaderstats" model, which is cloned into every player model (not character). u_g 90 — 10y
0
Did you try the code that I gave you? SilenceCore 25 — 10y
0
Thanks, it works. Sorry for doubting you before I tried it. I just adjusted it a bit so that in the backpack, it detects the leaderstats model by using "script.Parent.Parent.leaderstats.ChildAdded:connect(onChildAdded)". u_g 90 — 10y
0
Reputation pl0x SilenceCore 25 — 10y
View all comments (5 more)
0
"You need at least 1 reputation before you can upvote". u_g 90 — 10y
0
Try now SilenceCore 25 — 10y
0
Now it doesn't work. Sadly... u_g 90 — 10y
0
MAN, I feel dumb. I needed to put it in the StarterPack... because if I cloned it into the backpack, the backpack would be reset every single death, but the StarterPack would clone it every single death, as well. u_g 90 — 10y
0
Use ypcall(function() --script end) SilenceCore 25 — 10y
Ad

Answer this question