Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to Load player before script? HELP.

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

0

I could use a wait() but im trying to waitForChild and am struggling.

0

Don't you do player:WaitForChild("leaderstats")

0

At the bottom?

0

Didn't work.

1 answer

Someone let me know if this will work:

Localsceipt that waits for player to load then fires server event that has a script that listens for the fired event then creates the leaderboard. I think this will work, not able to test right now.

This discussion is preserved as it was. New answers, comments, and votes are closed.