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

How do I know if a child was added? [Easy problem]

Asked by 6 years ago

I have this script:

local player = script.Parent.Parent
repeat wait() until player.Character
game.Players.LocalPlayer.Character:WaitForChild("PlayerSkins").ChildAdded:connect(function(skin)
    print("Auto saving...")
    local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")--Player key
local statstorage = player.Character:WaitForChild("PlayerSkins"):GetChildren()
for i = 1, #statstorage do
    datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
    print(statstorage[i].Value.." Saved succesfully!")
    wait(.1)
end
print("Succesfully saved!")
end)


I want to test it but it won't do anything when a child is added.. Information: Script is a NORMAL SCRIPT Script is in STARTER PLAYER SCRIPTS

I tried: DescendentAdded ChildAdded And none worked.. How do I make it work???

1 answer

Log in to vote
0
Answered by 6 years ago

It needs to be a local script in game.StarterPlayer.StarterPlayerScripts

0
if you're gonna be so short why won't you use comments? bartekrabit 38 — 6y
0
I can't access datastore from a local script só there needs to be other way wilsonsilva007 373 — 6y
0
there isn't a way without RemoteEvents and RemoteFunctions SebbyTheGODKid 198 — 6y
Ad

Answer this question