Ad
Log in to vote
1

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

Asked by
Cuvette 222
1 month ago
Edited 1 month 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 2768 — 1mo
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 222 — 1mo
0
You forgot to parent the instance to workspace. M39a9am3R 2768 — 1mo
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 222 — 1mo
View all comments (2 more)
0
Post the whole code ;p RubenKan 1832 — 1mo
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 222 — 1mo

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
1
Answered by
Cuvette 222
1 month 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



Ad