Leaderstats isn't working!

I am making a Tycoon game. So I need a leaderstat for cash.

I made this script:

local players = game:GetService("Players")

	if player then
		local leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = player

		local Cash = Instance.new("NumberValue")
		Cash.Name = "Cash"
		Cash.Parent = player
		Cash.Value = 0

But right now, this script isn’t adding a new folder at all into my player. Also, a leaderboard isn’t popping up. In the output, there isn’t any wrong. And also in the script does it seem right.

Please help me out!

You made a mistake in your script.

Cash.Parent = player

The parent must be the leaderstats folder, not the player.

I changed it, but didnt turn out how i want. Still no leaderstats showing up

Didn’t turn out how you want? What do you mean?

Check if your playerlist is enabled. Because I replaced the parent of the Cash, tested it, and it is working as intended.

It’s not making an folder at all

This is a server script right?

Yes. ServerScriptService and a normal script. Not a Local.

Try removing the if statement at the start.

Still, nothing is showing up.

Maybe because the script is disabled?

Also, no the script is active!

Try this, I tested it out and it works.
You can set the instance parent as the second argument to Instance.new

	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	local Cash = Instance.new("IntValue", leaderstats)
	Cash.Name = "Cash"
	Cash.Value = 0

Its not working. I don’t know why!

It does, you have to place it into an empty server script inside server script service

It should be IntValue instead of NumberValue

NumberValues do work, this script was working for me

	local ls = Instance.new("Folder", plr)
	ls.Name = "leaderstats"
	local Cash = Instance.new("NumberValue", ls)
	Cash.Name = "Cash"

Make sure it is in a script In ServerScriptService

You probably have a 3rd party script interferring or you leaderboards are disabled.

1 Like

Here you go.

	local leaderstats = Instance.new("Folder",player);
	leaderstats.Name = "leaderstats";

	local Cash = Instance.new("NumberValue",leaderstats);
	Cash.Name = "Cash";
	Cash.Value = 0;

This works.

Oh there are other suggestions to similar scripts, didnt seen them whoops.

If nothing works, try running this script:

local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreEnabled(Enum.CoreGuiType.PlayerList, true)

For a second I thought you just copied my post. But its different