Solved text component not working?

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

Onliy

Member
Nov 28, 2024
4
0
1
24
I'm trying to make code that when click "[ OK. ]" in the book then player will execute the command but I definitely have an error with the code 'text component' but I installed Skellett, please help!

code_language.skript:
on script load:
    set {_ok} to text component "&a[ OK. ]"
    add click event with action RUN_COMMAND with execute "/test" to text component {_ok}

1734086682102.png
 
Skellett is not the best addon to use text components.
Instead, you should be using SkBee's implementation (which are more updated). Take a look at the wiki (there are plenty of examples)
 
Skellett is not the best addon to use text components.
Instead, you should be using SkBee's implementation (which are more updated). Take a look at the wiki (there are plenty of examples)
Ok i edited my code and it loaded successfully but it displayed as <none> can you help me to edit code?
this is my full code:
code_language.skript:
on script load:
    set {_warnok} to a new text component from "&a[ OK. ]"
    set click event of {_warnok} to a new click event to run command "/canyouremovewarnfrommebecausethisisverysans"

command /warn <offline player> [<text>]:
    permission: op
    trigger:
        if arg-2 is set:
            set {warntext::%arg-1%'s uuid} to arg-2
        else:
            set {warntext::%arg-1%'s uuid} to "&7&l&oEmpty"
        set {warn::%arg-1%'s uuid} to true
        set {_warnbook::%arg-1%'s uuid} to a written book
        set pages of {_warnbook::%arg-1%'s uuid} to "&c⚠ &lYOU GOT WARNED! &c⚠%nl%%nl%&c&lReason: %{warntext::%arg-1%'s uuid}%%nl%%nl%      %{_warnok}%"
        open book {_warnbook::%arg-1%'s uuid} to arg-1

every 1 tick:
    loop all players:
        if {warn::loop-player's uuid} is true:
            open book {_warnbook::loop-player's uuid} to loop-player

command /canyouremovewarnfrommebecausethisisverysans:
    trigger:
        clear {warn::player's uuid}
 
{_warnok} is a local variable, which is only accessible in the section it is created in. You should put it under the /warning command, then you should be fine
 
{_warnok} is a local variable, which is only accessible in the section it is created in. You should put it under the /warning command, then you should be fine
O.O I didn't know that was meaning local variable but click event to run command is not working
+I used warning command and player got warned so player's warn was set to true and i looped send player's warn value every 1 ticks and it says <none> so value got reseted i think can you help me this too?

(sry i suck at english)
 
Last edited:
your other variables are not 100% correct, either. You should change %arg 1%'s uuid to %arg 1's uuid% or even %uuid of arg 1%
 
your other variables are not 100% correct, either. You should change %arg 1%'s uuid to %arg 1's uuid% or even %uuid of arg 1%
Thank you thats working!!
code_language.skript:
but set click event of {_warnok} to a new click event to run command "/canyouremovewarnfrommebecausethisisverysans"
but this code is still not working can you help me this too?
 
I understand you want to but the click event in a book, but I'm not very experienced with that, i'm afriad. I do know, however, how to add click events to text directly in chat:
Code:
send formatted "&eChange your gamemode: <cmd:/gamemode creative>&bCreative"
This makes the text that appears in aqua (Creative) force the player to run the command /gamemode creative (obviously the player still needs permission to use the command, anyways)