plrEntered = function(plr)
local ls = Instance.new('IntValue') --Leaderstats
ls.Parent = plr
ls.Value = 0
ls.Name = 'leaderstats'
local stat = Instance.new('IntValue')
stat.Name = 'Cash' -- Change to the value you want
stat.Value = 0 -- Add the starting value
end
game:GetService'Players'.PlayerAdded(plrEntered)
That would be in a SSS, Server Script Service
Credits to: https://stackoverflow.com/questions/4272592/how-do-i-make-a-leaderboard-on-roblox
Hello, @hauntedzx try adding a script in ServerScriptService and pasting this in:
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr) -- Creates a Folder inside the Player Instance
leaderstats.Name = "leaderstats"
local PartCounter = Instance.new("IntValue",leaderstats) -- Creates a new IntValue inside the folder we creates
PartCounter.Name = "Parts"
for i,v in pairs(game.Workspace.Folder:GetChildren()) do -- This loop goes through the items inside the folder
if v:IsA("Part") then -- Checks if the item inside the folder is a Part
PartCounter.Value = i -- Changes the value if its a Part
end
end
end)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
local q = Instance.new("Folder", plr)
local w = Instance.new("IntValue", q)
local q.Name = "leaderstats" -- Don't change.
local w.Name = "Parts"
while true do
wait (.01)
w.Value = #workspace.Folder:GetChildren()
end
end)
-- Place in workspace / SSS (server script service)