I have a gen skript that works with no errors and works fine but when the owner of the gens leave they stop acting as gens and you can destroy them even if they are not yours, please tell how to fix that.
Code:
on block place:
if event-block is hay block:
if name of player's held item contains "&eWheat Gen":
if {gens::%player's uuid%} < 20:
set {%event-block%.owner} to player
add 1 to {gens::%player's uuid%}
add location of event-block to {placed::gens::%player's uuid%::*}
send action bar "&bYou placed a wheat gen!" to player
else:
cancel event
send action bar "&cYou have reached the max gens you can place!" to player
on left click:
if event-block is hay block:
Loop all players:
if {placed::gens::%loop-player's uuid%::*} contains location of event-block:
if player is sneaking:
if {%event-block%.owner} is set:
if {%event-block%.owner} is not player:
cancel event
send action bar "&cYou are not the owner of this gen!" to player
else:
cancel event
set event-block to air
remove 1 from {gens::%player's uuid%}
remove location of event-block from {placed::gens::%player's uuid%::*}
send action bar "&cYou broke a wheat gen!" to player
give player hay block named "&eWheat Gen"
else:
cancel event
send action bar "&bTo break a gen you need to be shifting." to player
on right click:
if event-block is hay block:
Loop all players:
if {placed::gens::%loop-player's uuid%::*} contains location of event-block:
if player is sneaking:
if {%event-block%.owner} is set:
if {%event-block%.owner} is not player:
send action bar "&cYou are not the owner of this gen!" to player
else if player's balance >= 2500:
wait 10 ticks
set event-block to pumpkin
send action bar "&bYou upgraded a gen!" to player
remove 2500 from player's balance
send "&b2500&a$ &bwere removed from your balance" to player
else:
send action bar "&bYou need %2500 - player's balance%&a$ &bmore to upgrade the gen" to player