Stopwatch

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

loadka95

Active Member
Feb 24, 2017
78
6
8
26
Im trying to make a stopwatch, but when i use the command its froze my server and i don't know why.

code_language.skript:
variables:
    {timer.%player%} = false
command /timer:
    trigger:
        set {timer.%player%} to true
        set {_start} to now
        display board named "StopWatch" to player
        while {timer.%player%} is true:
            set {_diff} to difference between now and {_start}
            make score of "Time" in board of player to {_diff}
command /timerstop:
    trigger:
        set {timer.%player%} to false
 
You need to add a delay to your while loop. It's going to repeat infinitely without any delay. So it could theoretically run it 100000 times a second.
code_language.skript:
variables:
    {timer.%player%} = false
command /timer:
    trigger:
        set {timer.%player%} to true
        set {_start} to now
        display board named "StopWatch" to player
        while {timer.%player%} is true:
            set {_diff} to difference between now and {_start}
            make score of "Time" in board of player to {_diff}
            wait 1 second
command /timerstop:
    trigger:
        set {timer.%player%} to false
 
Status
Not open for further replies.