Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a leaderstat that features your highest value on another leaderstat?

Asked by 4 years ago

Hello!

I'm working on a game where I have two leaderstats, TimeAlive and TopTime. I already have the TimeAlive figured out, but I'm wondering how I can make the TopTime. Does anyone know how I can do this?

2 answers

Log in to vote
0
Answered by 4 years ago

Hey, your problem can be solved simply by putting

TopTime.Value = tick()

this should work for time but I am not sure, I don't usually make time leaderstats.

0
When I put that, it just automatically made the TopTime value 1.6B value... KreativleV2 0 — 4y
0
You need to add wait(1) tomer495 19 — 4y
0
Still doesn't work. KreativleV2 0 — 4y
0
do tick(1) sorry TheQuitzzyKadren 29 — 4y
Ad
Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

Well i don't know how your architecture looks like so the answer might not be as like you needed but here is example of how to do it with simple variables:

local CurrentTime = 0
local MaxTime = 0

while true do
    wait(1)
    CurrentTime += 1
    if CurrentTime > MaxTime then
        MaxTime = CurrentTime
    end
end

Basically you should understand here, CurrentTime is the current time and MaxTime is your highest time. I have put while loop there so the time adds every second and at line 7 it checks if the current time is higher than your highscore time then it will set the MaxTimeto the CurrentTime.

Answer this question