I am making a skript that is a item editor with a gui and when I was adding enchanting I came across two different problems. First is closing the gui after the player clicks on enchant with efficiency. The other thing is enchanting the tool I just can't figure out how to transfer the chat from the player to the enchantment level. Here is my code below.
on inventory click:
if event-inventory = (metadata tag "Tools" of player):
cancel event
if index of event-slot is 2:
if player is holding air:
message "&7You need to be holding the item you would like to enchant" to player
else:
message "&7Put the level in chat" to player
set {-enchantlvl::%player%} to true
close (metadata tag "Tools" of player) to player
on chat:
if {-enchantlvl::%player%} is true:
cancel event
clear {-enchantlvl::%player%}
set {_enchant::%player%} to message
enchant player's tool with "efficiency %{_enchant::%player%}%" parsed as enchantment type
on inventory click:
if event-inventory = (metadata tag "Tools" of player):
cancel event
if index of event-slot is 2:
if player is holding air:
message "&7You need to be holding the item you would like to enchant" to player
else:
message "&7Put the level in chat" to player
set {-enchantlvl::%player%} to true
close (metadata tag "Tools" of player) to player
on chat:
if {-enchantlvl::%player%} is true:
cancel event
clear {-enchantlvl::%player%}
set {_enchant::%player%} to message
enchant player's tool with "efficiency %{_enchant::%player%}%" parsed as enchantment type