How do i make a gui that shows ur own leaderstat

i have a leaderstat for how much time the player has spent in game and i wanted to show that as a GUI as i was planning on hiding the leader board, could you help me?

1 Like

Here’s an example script I think that will help you.

local TextLabel = script.Parent:FindFirstChild("YourTextLabelNameHere") -- The text that will show the stats.
while wait() do
  local Stats = game.Players.LocalPlayer:FindFirstChild("YourLeaderStatsFolderName") -- The leaderstats folder
  TextLabel.Text = Stats:FindFirstChild("PlayerTimeValue").Value -- The time value in the folder.
end

(You can also use .Changed event for this as well.)

where do i put the script? im new to scripting

You can put the script in the GUI. (The script must be a LocalScript.)

1 Like

For the leaderboard removal, you could just call this on a LocalScript:

game.StarterGui:SetCoreGuiEnabled("Playerlist", false)

For the leaderstat, you could implement a PlayerAdded event in a Server Script that fires for every individual player that joins the game to each give the leaderstats:

game.Players.PlayerAdded:Connect(function(Player)
    local TimeStat = Instance.new("NumberValue")
    TimeStat.Name = "IngameTime"
    TimeStat.Parent = Player

    while true do
        wait(1)
        TimeStat.Value += 1
    end
end)

The example script the above post gave, is actually updating the GUI

Also @TheRealANDRO I wouldn’t recommend calling FindFirstChild when attempting to find a leaderstat on a LocalScript, it may not instantly find the Instance & could result as a nil value:

local TextLabel = script.Parent:WaitForChild("YourTextLabelNameHere")
local Player = game.Players.LocalPlayer
local TimeStat = Player:WaitForChild("IngameTime")

TimeStat.Changed:Connect(function(NewValue)
    TextLabel.Text = tostring(NewValue)
end)
1 Like

It’s pretty much up to them.
Also, I think they’ve already done the first part.

1 Like

how do i use this script? i tried and it didnt show leaderstat.

That should is actually 1 of the Main Game scripts that you’ll use, so it should go in ServerScriptService

wait i did that and it didnt show the stat

Aren’t you wanting to hide the leaderstats if I’m not mistaken? If you aren’t, then just add a Folder named “leaderstats” before you create your TimeStat variable & parent it to the player, then parent your TimeStat to the Folder

I’m using this script to show the player’s time how much the player played.

This script must be handled via server.

-- You can change the variables and also create a folder to store IntValues
if player.TimePlayed.Second.Value == 59 then
	wait(1)
	player.TimePlayed.Second.Value = 0
	player.TimePlayed.Minute.Value = player.TimePlayed.Minute.Value + 1
end

while second.Value < 59 do

	wait(1)

	second.Value = second.Value + 1

	if second.Value == 59 then
		wait(1)
		second.Value = 0

		if minute.Value < 59 then
			minute.Value = minute.Value + 1
		end

		if minute.Value == 59 then
			minute.Value = 0
			hour.Value = hour.Value + 1
		end
	end
end	

You must use LocalScript in a TextLabel or something else to show the player’s value.

while true do
    wait(1)
    script.Parent.Text = hour.Value ..":".. minute.Value ..":".. second.Value
end