GUI with all online players

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

    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!

MongoTV

Member
Jul 12, 2025
3
1
3
Can anyone help me

Im making a GUI with playerheads of all online players and when a playerhead is clicked on i need to execute a command with the players name
 
Can anyone help me

Im making a GUI with playerheads of all online players and when a playerhead is clicked on i need to execute a command with the players name
This works the best imo.


Code:
function OnlinePlayers(p: player, page: number):
    set {page::%uuid of {_p}%} to {_page}
    set {_OnlinePlayers} to chest inventory with 6 rows named "Online players"
    set slot (integers between 45 and 53) of {_OnlinePlayers} to black stained glass pane named "&7"
    set slot 45 of {_OnlinePlayers} to spectral arrow named "&6&lGo Back"

    set {_start} to {_page} * 45
    set {_end} to {_start} + 44
    set {_slot} to 0
    set {_index} to 0
    set {_total} to size of all players

    loop all players:
        if {_index} is between {_start} and {_end}:
            set {_head} to skull of loop-player
            set name of {_head} to "&a%name of loop-player%"
            set slot {_slot} of {_OnlinePlayers} to {_head}
            add 1 to {_slot}
        add 1 to {_index}

    if {_page} > 0:
        set slot 48 of {_OnlinePlayers} to arrow named "&6« Previous"
    if {_total} > {_end}:
        set slot 50 of {_OnlinePlayers} to arrow named "&6Next »"
        
    open {_OnlinePlayers} to {_p}




on inventory click:
    if name of event-inventory contains "Online players":
        play sound "BLOCK_AMETHYST_BLOCK_RESONATE" to player
        cancel event

        if event-slot is 48:
            if event-item is arrow named "&6« Previous":
                subtract 1 from {page::%uuid of player%}
                OnlinePlayers(player, {page::%uuid of player%})

        if event-slot is 50:
            if event-item is arrow named "&6Next »":
                add 1 to {page::%uuid of player%}
                OnlinePlayers(player, {page::%uuid of player%})

        



command /menu:
    trigger:
        OnlinePlayers(player, 0)
 
This works the best imo.


Code:
function OnlinePlayers(p: player, page: number):
    set {page::%uuid of {_p}%} to {_page}
    set {_OnlinePlayers} to chest inventory with 6 rows named "Online players"
    set slot (integers between 45 and 53) of {_OnlinePlayers} to black stained glass pane named "&7"
    set slot 45 of {_OnlinePlayers} to spectral arrow named "&6&lGo Back"

    set {_start} to {_page} * 45
    set {_end} to {_start} + 44
    set {_slot} to 0
    set {_index} to 0
    set {_total} to size of all players

    loop all players:
        if {_index} is between {_start} and {_end}:
            set {_head} to skull of loop-player
            set name of {_head} to "&a%name of loop-player%"
            set slot {_slot} of {_OnlinePlayers} to {_head}
            add 1 to {_slot}
        add 1 to {_index}

    if {_page} > 0:
        set slot 48 of {_OnlinePlayers} to arrow named "&6« Previous"
    if {_total} > {_end}:
        set slot 50 of {_OnlinePlayers} to arrow named "&6Next »"
       
    open {_OnlinePlayers} to {_p}




on inventory click:
    if name of event-inventory contains "Online players":
        play sound "BLOCK_AMETHYST_BLOCK_RESONATE" to player
        cancel event

        if event-slot is 48:
            if event-item is arrow named "&6« Previous":
                subtract 1 from {page::%uuid of player%}
                OnlinePlayers(player, {page::%uuid of player%})

        if event-slot is 50:
            if event-item is arrow named "&6Next »":
                add 1 to {page::%uuid of player%}
                OnlinePlayers(player, {page::%uuid of player%})

       



command /menu:
    trigger:
        OnlinePlayers(player, 0)
How do i make it execute a command for the player clicked on? example "/fly player"
 
How do i make it execute a command for the player clicked on? example "/fly player"
You can add this.

Code:
if event-slot is between 0 and 44:
            set {_clickedName} to uncolored name of event-slot
            loop all players:
                if name of loop-player is {_clickedName}:
#your code here