Apparently leaderstats is not in the player when this script runs. I added a WaitForChild but that doesn't seem to help at all. Any ideas?
lead = game.Players.LocalPlayer.leaderstats
local Leaderboard = game.Players.LocalPlayer:WaitForChild("leaderstats")
Leaderboard.RankVal.Changed:connect(function(value)
if value == 1 then lead.Rank.Value = "Newbie" elseif
value == 2 then lead.Rank.Value = "Member" elseif
value == 3 then lead.Rank.Value = "Forager" elseif
value == 4 then lead.Rank.Value = "Watcher" elseif
value == 5 then lead.Rank.Value = "Night Watcher" elseif
value == 6 then lead.Rank.Value = "Warrior" elseif
value == 7 then lead.Rank.Value = "Runner" elseif
value == 8 then lead.Rank.Value = "Elder"
end
end)
print("Leaderboard is running.")
function onPlayerEntered(newPlayer)
wait(.5)
local stats = Instance.new("StringValue")
stats.Name = "leaderstats"
local stats2 = Instance.new("StringValue")
stats2.Name = "Tycoon"
local cash = Instance.new("IntValue")
cash.Name = ""
cash.Value = nil
local val = Instance.new("IntValue")
val.Name = "RankVal"
val.Value = 1
--check if the player owns your gamepass
if game:GetService("MarketplaceService"):PlayerOwnsAsset(newPlayer, 384198804) then
cash.Value = 10 -- change cash to 500,000 (can't have a comma)
else
cash.Value = 1
end
cash.Parent = stats
stats2.Parent = newPlayer
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)

3 comments
Take out the first line
Okay now I'm getting another error. It's telling me that RankVal does not exist. How can this be if I create it? I check in a studio test and it does not create itself within the player.
I'll post an asnwer