Solved Return a GUI from a function

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

JuliHatSpaB

Member
Aug 18, 2023
47
1
8
I want to make a function with returns a gui. But I don't know what variable type to use...

Code:
function gui() :: gui:
    set {_gui} to a new chest inventory with 3 rows named "&6&lGUI"
    return {_gui}
I get an Error in line 1: Can't recognise the type "gui".
What variable type do I have to use to return a gui?
 
Code:
function gui() :: inventory
Thanks!
And I also have another question:
If I want to give a function a player name with I can use in the function. How do I do that? Like:

Code:
command /gui:
    trigger:
        open gui("%player%") to player
function gui(play: string) :: gui:
    set {_gui} to a new chest inventory with 3 rows named "&6&lGUI"
    if {_play} has permission "sk.admin":
        set slot 4 of {_gui} to grass block named "&c&lADMIN"
    return {_gui}
But here the code won't return any errors but the slot 4 will also never be set...
 
You should pass the player object in directly, not their name. So your function should look something like this:
Code:
function gui(p: player) :: inventory:
And then you call it like:
Code:
command /example:
    trigger:
        open gui(player) to player
 
  • Like
Reactions: NixTer