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

Is there any way you could put a "Cash" Leaderboard and a "TimePlayed" Leaderboard in one game?

In my game I want to have 2 leaderboards a "Cash" leaderboard and a "Time Played" leaderboard! Thank you if you could answer this and could give me a script/scripts!

3 comments

0

This is not a request site. Please post when you have a question about scripting or a script you have made yourself.

0

This is a request which is not allowed. Although to help you, read this Wiki article and I believe it will help you with all you want and then some. http://wiki.roblox.com/index.php?title=Leaderboard

0

Scripting Helpers is NOT a request site; We do NOT make scripts for you. You must first attempt at making the script, then if that doesn't work, ask the Question, and provide the code you attempted with!

1 answer

✓ Accepted answer

You don't need 2 separate leaderboard scripts, and if you use 2 it will only display 1 them To create a leaderboard you need to create an IntValue (instance) and it HAS TO be named "leaderstats" (all lowercase) to create an Instance you use

local stats = Instance.new("IntValue")

Now you need to place it in the player, which is triggered when the player enters

game.Players.PlayerAdded:connect(function(Player)
local stats = Instance.new("IntValue", Player) --The Second Argument of (Instance.new) is where to place the new instance
stats.Name = "leaderstats" --This is to make it pop up in the leaderboard, if you don't do this it will enter the player as "IntValue"
end)

To add Values to the leaderstats you simply create a new IntValue``Instance and place it in the leaderboard

game.Players.PlayerAdded:connect(function(Player)
local stats = Instance.new("IntValue", Player)
local cash = Instance.new("IntValue", stats) --This places "cash" into the leaderstats
local time = Instance.new("IntValue", stats)
cash.Name = "Cash"
time.Name = "Time Played"
stats.Name = "leaderstats"
end)

Now to answer your Time Played question: Add while , do function to your script

game.Players.PlayerAdded:connect(function(Player)
local stats = Instance.new("IntValue", Player)
local cash = Instance.new("IntValue", stats)
local time = Instance.new("IntValue", stats)
cash.Name = "Cash"
time.Name = "Time Played"
stats.Name = "leaderstats"

while wait(1) do --This displays how many "SECONDS" the player had been playing, change wait(1) to wait(60) to display minutes
stats.Value = stats.Value + 1
end)

Hope this helped, also please keep in mind these values don't save to the player when they leave, thats a completely different script. Please do not post requests to this website, this is for help. Next time just post an attempt of your script.

If I helped Accept my answer please. And Thank you

EDIT NOTE: If you need to (for some reason) need to add "Cash" and "Time Played" to separate scripts then don't re-add "leaderstats", just put the new Value into Player.leaderstats

2 comments

0

I think it would work with 2. As long as only one creates a leaderstats and the other adds a value into it, while each player has that value as well.

0

You are very right thanks

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