Gens stops working on leave

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

Status
Not open for further replies.

MrSnowy

New Member
Sep 7, 2021
9
0
1
23
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
 
What the... is this code?

- "loop all players"
- mixed variables
- not using list variables
- starting a variable with an expression

C'mon...?
Hey I am just a begginer to skripting, also it's just a part of the code, you could be more helpful, if you can help me then thank you
[doublepost=1632480915,1632398709][/doublepost]
 
Status
Not open for further replies.