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

Load Instance Script Will Not Function As Expected?

Asked by
sammiya1 134
8 years ago
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

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question