Need help loading player before script. Ive literally tried everything I can think of and googled so much.
local DSS =game:GetService("DataStoreService")
local Money =DSS:GetDataStore("Cash")
local Bounty =DSS:GetDataStore("Bounty")
game.Players.PlayerAdded:connect(function(player)
local pCash = Money:GetAsync(player.UserId) or 0
local pBounty = Bounty:GetAsync(player.UserId) or 0
local leaderstats = Instance.new("IntValue",player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local CashValue = Instance.new("IntValue")
CashValue.Name = "Money"
CashValue.Value = pCash
CashValue.Parent = leaderstats
local BountyValue = Instance.new("IntValue")
BountyValue.Name = "Bounty"
BountyValue.Value = pBounty
BountyValue.Parent = leaderstats
CashValue.Changed:connect(function(v)
Money:SetAsync(player.UserId,v)
print("Money Has Been Saved for user")
end)
BountyValue.Changed:connect(function(v)
Bounty:SetAsync(player.UserId,v)
print("Bounty Has Been Saved for user")
end)
end)

4 comments
I could use a wait() but im trying to waitForChild and am struggling.
Don't you do player:WaitForChild("leaderstats")
At the bottom?
Didn't work.