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

[Solved] Player:WaitForDataReady() isn't loading at all?

Asked by
Cuvette 246 Moderation Voter
7 years ago
Edited 7 years ago

Here is the snippet below, I'm having trouble with the function carrying on after I use WaitForDataReady() I need to use this due to loading brick instances into the game that have been saved for the player. If this isn't before :LoadInstance then it simply asks me to use it, I've tried using Wait()'s but i'm guessing somewhere along the lines the player isn't fully loading in.

- Update - As requested, here is the whole script, although there's no need for it because it doesn't get past the 5th line.

local DataStore = game:GetService("DataStoreService"):GetDataStore("CashStore1")

game.Players.PlayerAdded:connect(function(player)
    --wait(6)
    player:WaitForDataReady()
    local movearea = game.Workspace.Tycoons.GoldMine1.BoundingArea
    print("Player Ready, Loading Gold Mine")
    Parts = player:LoadInstance("GoldRush-Alpha1")
    Parts.PrimaryPart = Parts.BoundingBox
    Parts:SetPrimaryPartCFrame(CFrame.new(movearea.Position.X,movearea.Position.Y-1,movearea.Position.Z) * CFrame.Angles(0, math.rad(movearea.Rotation.Y), 0))
    Parts.Parent = game.Workspace.Tycoons.GoldMine1.Objects

    local key = "player-"..player.userId    
    local savedValues = DataStore:GetAsync(key)
    if savedValues then
        local Cash = Instance.new("IntValue",game.ServerStorage.MoneyStorage)
        Cash.Name = player.Name
        Cash.Value = savedValues[1] 
        local money = Instance.new("IntValue")
        money.Name = "Cash"
        money.Value = savedValues[1]
        money.Parent = player.leaderstats
    else
        local money = Instance.new("IntValue")
        money.Name = "Cash"
        money.Parent = player.leaderstats
        local valuesToSave = {player.leaderstats.Cash.Value}
        DataStore:SetAsync(key, valuesToSave)
        local Cash = Instance.new("IntValue",game.ServerStorage.MoneyStorage)
        Cash.Name = player.Name
        Cash.Value = 60 
        money.Value = Cash.Value
    end
end)
0
Are you getting an error on the LoadInstance line? M39a9am3R 3210 — 7y
0
Only If I take away WaitForDataReady(). Otherwise it won't error at all or load the instance. I've tried it on several scripts in the same game and the same thing happens. It must be stuck on the Wait line. I couldn't find any problems with loading the player such as stats and things like that, is there a way to bypass WaitForDataReady() and just load the instance? Cuvette 246 — 7y
0
You forgot to parent the instance to workspace. M39a9am3R 3210 — 7y
0
I've got all of that underneath, I could even delete everything and put a simple Print("Hello") underneath and it wouldn't print. The WaitForDataReady line doesn't work anywhere in any script of mine on this game. And i'm not sure how to locate why and what is preventing it from loading in. Cuvette 246 — 7y
View all comments (2 more)
0
Post the whole code ;p RubenKan 3615 — 7y
0
I have done, there's not much point though because it still doesn't do anything past WaitForDataReady so anything below it is not causing a problem. Cuvette 246 — 7y

1 answer

Log in to vote
1
Answered by
Cuvette 246 Moderation Voter
7 years ago

It was only a simple solution, if any. For some reason WaitForDataReady() only works online. Which is a pain when you need to test your game every minute or so.

Ad

Answer this question