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)
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.