• 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!

Jul 18, 2023
34
0
6
16
Hi there! I'm trying to make an in-game music Skript where it loops the cat disc. I calculated the exact number of minutes the disc is (im using a texture pack) and when I play it in-game it works but the sound plays over itself. I can't figure out how this happens. Here is my code:

Code:
command /thiscommanddoesnothingmusic:
    trigger:
        execute console command "execute at %player% run playsound music_disc.cat player %player% ~ ~ ~ 999999999999999999"
        wait 2 minutes
        wait 15.33 seconds
        make player execute command "thiscommanddoesnothingmusic"
on join:
    wait 25 seconds
    make player execute command "thiscommanddoesnothingmusic"

It'd be great if you helped! :emoji_grinning:
 
Hi there! I'm trying to make an in-game music Skript where it loops the cat disc. I calculated the exact number of minutes the disc is (im using a texture pack) and when I play it in-game it works but the sound plays over itself. I can't figure out how this happens. Here is my code:

Code:
command /thiscommanddoesnothingmusic:
    trigger:
        execute console command "execute at %player% run playsound music_disc.cat player %player% ~ ~ ~ 999999999999999999"
        wait 2 minutes
        wait 15.33 seconds
        make player execute command "thiscommanddoesnothingmusic"
on join:
    wait 25 seconds
    make player execute command "thiscommanddoesnothingmusic"

It'd be great if you helped! :emoji_grinning:
You could just do
Code:
play sound "music_disc.cat" to player
. Also, you can combine a couple lines.
Code:
wait 2 minutes and 15.33 seconds
. Also you could try adjusting the time slightly to wait a little bit of time until after the sound has stopped playing before playing it again.
 
You could just do
Code:
play sound "music_disc.cat" to player
. Also, you can combine a couple lines.
Code:
wait 2 minutes and 15.33 seconds
. Also you could try adjusting the time slightly to wait a little bit of time until after the sound has stopped playing before playing it again.
Here is my new code:


Code:
command /thiscommanddoesnothingmusic:
    trigger:
        execute console command "stopsound %player% player"
        wait 1 tick
        execute console command "execute at %player% run playsound music_disc.cat player %player% ~ ~ ~ 999999999999999999"
        wait 136 seconds
        execute console command "stopsound %player% player"
        wait 1 tick
        execute console command "execute at %player% run playsound music_disc.mall player %player% ~ ~ ~ 9999999999999999999"
        wait 105 seconds
        make player execute command "thiscommanddoesnothingmusic"
on join:
    wait 28 seconds
    send action bar "&bJoin our discord to apply for ranks! &9(/discord)"
    make player execute command "thiscommanddoesnothingmusic"

Somehow is still overlaps, it should work perfectly though
 
I also encountered this problem. I tried to play the soundpack of resourcepack, but the music on the client side overlapped..
For example, when I play my custom music, the default randomly played music in the client will also play, resulting in two different pieces of music playing together

Code:
function MusicAPI_PlaySound(player: player, music:text, sec:number, world:text):
    clear {-MusicAPI::%{_world}%_bgm_seconds::%{_player}%}

    if {_player}'s world is not {_world}:
        stop

    while {_player} is online:
        wait 1 seconds

        play sound {_music} in music category with volume 1 to {_player}

        set {-MusicAPI::%{_world}%_bgm_seconds::%{_player}%} to 0
        while {_player} is online:
            wait 1 seconds
            add 1 to {-MusicAPI::%{_world}%_bgm_seconds::%{_player}%}

            if {-MusicAPI::%{_world}%_bgm_seconds::%{_player}%} >= {_sec}:
                stop loop

            if {_player}'s world is not {_world}:
                clear {-MusicAPI::%{_world}%_bgm_seconds::%{_player}%}
                stop sound {_music} for {_player}
                stop
 
Last edited: