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

Load Instance Script Will Not Function As Expected?

game.Players.PlayerAdded:connect(function(p)
    p:WaitForDataReady()
    if p:LoadInstance() == nil then
        game.ReplicatedStorage.CreateAToon.Rooms:Clone().Parent = game.Workspace
    end)
end

what it should do is check p which is the player for any save instances then if there is none represented by nil, it should spawn a create room. But it does nothing at all except give me some errors in dev console. Errors Link: http://prntscr.com/brmv15 http://prntscr.com/brmvou

1 answer

✓ Accepted answer

You are missing a closing bracket for the connect function. It should look like this:

game.Players.PlayerAdded:connect(function(p)
    p:WaitForDataReady()
    if p:LoadInstance() == nil then
        game.ReplicatedStorage.CreateAToon.Rooms:Clone().Parent = game.Workspace
    end
end)

Another thing I noticed is that you are not passing anything to LoadInstance, when you should be passing the key for what you're trying to load.

Finally, you should probably use Data Stores, rather than data persistence, however these are a bit more complicated.

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