Help with Back Slot Skript

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

firephrog

Member
Apr 1, 2024
3
0
1
24
So i am making a skript for backslots. Im trying to get it to look like the item is on the player's back with this code

Code:
command /backslot:
    trigger:
        spawn armor stand at player
        set {_stand} to last spawned armor stand
        set tool of {_stand} to player's tool
        set name of {_stand} to "%player%'s backslot"
        set {_n} to nbt compound from "{Invisible:1}"
        add {_n} to nbt of last spawned armor stand
        set {_n} to nbt compound from "{NoGravity:1}"
        add {_n} to nbt of last spawned armor stand
        set {_yaw} to location 0.3 meters left of player
        add 90 to yaw of {_yaw}
        teleport {_stand} to {_yaw}
        
every tick:
    loop all players:
        set {_yaw} to location 0.3 meters left of loop-player
        add 90 to yaw of {_yaw}
        teleport {_stand} to {_yaw}

It isn't moving the armor stands to the player nor registering the variable. Please help
 

Attachments

  • backslot.sk
    725 bytes · Views: 87
This is because you're using local variables (variable names prefixed with _) which get deleted after the event ends. You can fix this by replacing {_stand} with {stand::%player's uuid%} and {_yaw} with {yaw::%player's uuid%} (so you have a unique variable for every player). Also, instead of an every 1 tick loop all players, you could use an on player move event.

Further, you should make the /backslot command toggle the backslot. The first time, it summons the stand and sets a player's uuid variable to true. The second time, it deletes all the variables and sets the true variable to false. And then it repeats for every time you use the command.

Make sure that your on player move/every 1 tick events check if that player's uuid variable is true so that it doesnt call when theres nothing to teleport.
 
This is because you're using local variables (variable names prefixed with _) which get deleted after the event ends. You can fix this by replacing {_stand} with {stand::%player's uuid%} and {_yaw} with {yaw::%player's uuid%} (so you have a unique variable for every player). Also, instead of an every 1 tick loop all players, you could use an on player move event.

Further, you should make the /backslot command toggle the backslot. The first time, it summons the stand and sets a player's uuid variable to true. The second time, it deletes all the variables and sets the true variable to false. And then it repeats for every time you use the command.

Make sure that your on player move/every 1 tick events check if that player's uuid variable is true so that it doesnt call when theres nothing to teleport.
ohh thats what the _ was for