code_language.skript:
command /Spectator:
aliases: spectate
trigger:
if {Spec::%player%} is not set:
set {Spec::%player%} to 1
play sound "block.anvil.place" at player
set the player's game mode to creative
send "{@P} &7Spectator mode &aenabled"
if {Spectate} is set:
teleport player to {Spectate}
send "{@P} &7Sent to &5spectate &7location"
else:
send "{@P} &cSpectate location not set, tell an admin"
loop all items in the inventory of player:
add loop-item to {SpecI:%player%::*}
remove loop-item from the player
else:
delete {Spec::%player%}
play sound "block.anvil.place" at player
set the player's game mode to survival
send "{@P} &7Spectator mode &cdisabled"
execute console command "/spawn %player%"
set {_slot} to 1
loop {SpecI:%player%::*}:
add 1 to {_slot}
set slot {_slot} of player's inventory to loop-value
delete {SpecI:%player%::*}
stop
im trying to make it so it deletes and saves the inventory on the command toggle ON but on the toggle OFF i want it to restore the inventory. so far it only restores 1 item