Why is leaderstats not showing in studio?

i know am dumb but for some reason leaderstats wont show! its in serverscriptservice
am 99% sure that this piece script works but it doesnt???

game.Players.PlayerAdded:Connect(function(plr)
local leader = Instance.new(“Folder”, plr)
leader.Name = “Leaderstats”
local stat = Instance.new(“IntValue”, leader)
stat.Name = “Cash”
stat.Value =0
end)

1 Like
game.Players.PlayerAdded:Connect(function(plr)
local leader = Instance.new("Folder", plr)
leader.Name = "leaderstats"
local stat = Instance.new("IntValue", leader)
stat.Name = "Cash"
stat.Value = 0
end)

test it

1 Like

This would be work, because Roblox checks for a folder inside the player named “leaderstats”. Capitalization is important for this.

2 Likes

ooohhh thanks alot! that would make more sense

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Value = 0
	cash.Parent = leaderstats
end)

It’s generally considered a bad practice to use the optional “Parent” parameter of the function “Instance.new()”, you can read more about this here:

1 Like

The folder has been named “leaderstats” unless the post was edited.