Hey, I'm new to scripting and would like to know how to make a leaderboard or leaderstats thats filter enabled so everyone will be able to see when a value change.
I've tried the code below from the wiki, but I want know how to make it so when you click on a text button your "Cash" will increase and other people will see it.
Also is there any easier way to filter enabled a leaderboard other than the one shown below? Thank you for your time. xd
ps. what are those brackets "[]" for and "_, player" mean.
-- Table for holding each player's 'leaderstat' values
local playerLeaderStats = {}
-- Function that executes when a player is added to the game
game.Players.PlayerAdded:connect(
function(player)
playerLeaderStats[player] = {} -- Add a sub-table for the player to the 'playerLeaderStats' table
playerLeaderStats[player]["Money"] = 0 -- Add a 'Money' key with value of 0
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player -- Parent the 'leaderstats' object to the player
local money = Instance.new("IntValue") -- Create a new 'IntValue'
money.Name = "Money" -- The name of the in-game leader stat
money.Value = playerLeaderStats[player]["Money"]
money.Parent = leaderstats -- Set the money object as a child of the 'leaderstats' object
end
)
while wait(5) do
for _, player in ipairs(game.Players:GetPlayers()) do
if player:FindFirstChild("leaderstats") then
-- Don't use the 'IntValue' value because an exploiter can modify it!
playerLeaderStats[player]["Money"] = playerLeaderStats[player]["Money"] + 1
player.leaderstats.Money.Value = playerLeaderStats[player]["Money"]
end
end
end

1 comment
Thanks for helping out!