I've scripted a moneyGiver, moneySpend, itemDropper and leaderboardSystem. . They all have their own custom functions as: moneyGiver(), moneySpend(), itemDropper() and leaderboardSystem().
Occasionally, for some reason the leaderboard can be found in the Player and sometimes it isn't found. When I test the game in a server, the moneyGiver works completely fine. So does the itemDropper, and so does the leaderboard. However, when I click the moneySpend pad, it is supposed to deduct cash. Yet, it doesn't and says that the leaderstats cannot be found inside the Player. I have no idea how I would be able to fix this.
The screenshot with the error and code can be found here: http://prntscr.com/jqz3hb
Thank you. :)
~Nixvoid
Your leaderboard system is loading after the moneySpend script has run
local stats = game.Players:FindFirstChildOfClass("Player"):WaitForChild("leaderstats") local cash = game.Players:FindFirstChildOfClass("Player"):WaitForChild("leaderstats"):WaitForChild("Cash")
game.Players.PlayerAdded:connect(function() local stats = Instance.new("Model") **stats.Name = "leaderstats"********** local money = Instance.new("NumberValue") money.Parent = stats stats.Parent = game.Players.LocalPlayer end)