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)

6 comments
Are you getting an error on the LoadInstance line?
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?
You forgot to parent the instance to workspace.
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.
Post the whole code ;p
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.