Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

After doing InsertService:LoadAsset() game.Players.PlayerAdded does not run?

local itemScript = game:GetService("InsertService"):LoadAsset(3723749360):GetChildren()[1]
itemScript.Parent = game.ReplicatedStorage
game.Players.PlayerAdded:Connect(function()
	print('hi')
end)

It does not print('hi') if I remove the insert, it works. If anyone could give me some insight into this, it would be appreciated.

3 comments

0

the id might be messed up

0

it works when I type it into the command bar

0

suertudo bro la dueña de sh te contestó

1 answer

✓ Accepted answer

LoadAsset yields when you call it, which means it takes time to return. You're connecting PlayerAdded after it loads, which is too late. The player already joined by the time you connect the event.

Connect your event before you call LoadAsset, or loop over all players currently in the game and call a function on them after you connect the event.

This discussion is preserved as it was. New answers, comments, and votes are closed.