I have a weapon level system but i dont understand why it doesnt work like when i right click (i set it so for testing) it gives xp but the max xp breaks and goes to none can anyone help?
Code:
on right click with a sword:
if name of player's tool is "&aLeveled Sword":
set {_lore} to uncolored line 1 of lore of player's tool
set {_level_text::*} to {_lore} split at " "
set {_level} to {_level_text::2} parsed as number
set {_xp_section} to {_level_text::3} # This is "(0/100 XP)"
set {_xp_section::*} to {_xp_section} split at "/"
set {_current_xp} to {_xp_section::1} parsed as number
set {_max_xp_text} to {_xp_section::2} split at " " # Split to remove " XP"
set {_max_xp} to {_max_xp_text::1} parsed as number # Parse the number
add 10 to {_current_xp}
if {_current_xp} >= {_max_xp}:
subtract {_max_xp} from {_current_xp} # Carry over excess XP
add 1 to {_level} # Increase the level
set {_max_xp} to {_max_xp} * 2 # Double the max XP required for the next level
send "Your sword leveled up to level %{_level}%!" to player
set line 1 of lore of player's tool to "Level %{_level}% (%{_current_xp}%/%{_max_xp}% XP)"
send "XP: %{_current_xp}%/%{_max_xp}%, Level: %{_level}%" to player