Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you check for a specific players name for leaderboard stats?

Was using a leaderboard and wanted to be able to set specific players' leaderstat to something different than another leaderstat. hers the script if needed:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect (function(Player)
	if Player		
	then
		local Folder = Instance.new('Folder')
		Folder.Name = ("leaderstats")
		Folder.Parent = Player
		
		local Power = Instance.new("IntValue")
		Power.Name = ("Power")
		Power.Parent = Folder
		Power.Value = Players.
	end
end)

Edit: I figured it out, by putting a script in one of the replicated folders, such as PlayerGUI, then you can detect and run a function based on the player's name value.

if script.Parent.Parent.Name == "PlayersName" then
	script.Parent.Parent.leaderstats.Power.Value = 100
else
end

In this example, I put the script in the ScreenGUI folder and made it search for the Player's Name, then edited the IntValue in the "leaderstats" folder if the players name was equal to the String Value.

2 comments

0

Not sure what you meant by that. Are you trying to check player's leaderstats or set it?

0

Trying to set someone's leaderstat, as an example I want PlayerB's value to be 100 while playerA's is 0, I only need PlayerB's to be 100, so if PlayerC joined his would be 0 by default but PlayerB's would be 100 by default if he joined

2 answers

By putting a script in one of the replicated folders, such as PlayerGUI, then you can detect and run a function based on the player's name value.

As I understand it, you want specific players to have a set amount when they join, correct? You can put the players' names on a table and the amount they will receive

local Players = game:GetService("Players")

local DefaultValue = 10 --will be given to players who are not found at the table

local Table = {
  ['PlayerName'] = 50,
  ['AnotherPlayer'] = 250,
}

Players.PlayerAdded:Connect (function(Player)
        local Folder = Instance.new('Folder')
        Folder.Name = ("leaderstats")
        Folder.Parent = Player

        local Power = Instance.new("IntValue")
        Power.Name = ("Power")
        Power.Parent = Folder
	Power.Value = Table[Player.Name] or DefaultValue
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.