Solved Variable not working right?

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

    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.

DiufoemHD

Member
May 29, 2018
3
0
0
Skript Version:Not Sure
Skript Author:Not Sure
Minecraft Version:1.12.2

---
Full Code: Most of the code works, it's just this specific part.
code_language.skript:
    if inventory name of the player's current inventory is "&bFreeze":
        clicked item is head
        if {freeze.%{_p}%.frozen} is 0:
            set {_p} to uncolored item's name parsed as player
            set {freeze.%{_p}%.frozen} to 1
            set {freeze.%{_p}%.location} to location of {_p}
            send "&b%{_p}% has been frozen!" to player
            send "&bYou have been frozen!" to {_p}
            close player's inventory
            cancel event
            stop
        if {freeze.%{_p}%.frozen} is 1:
            set {_p} to uncolored item's name parsed as player
            set {freeze.%{_p}%.frozen} to 0
            delete {freeze.%{_p}%.location}
            send "&b%{_p}% has been unfrozen!" to player
            send "&bYou have been unfrozen!" to {_p}
            close player's inventory
            cancel event
            stop
        else:
            set {_p} to uncolored item's name parsed as player
            send "&cWe're sorry! Some how DabbingFoem glitched the freeze command. %{_p}% should be unfrozen." to the player
            set {freeze.%{_p}%.frozen} to 0
            close player's inventory
            cancel event
            stop

every second:
    loop all players:
        if {freeze.%loop-player%.frozen} is 1:
            teleport loop-player to {freeze.%loop-player%.location}

Errors on Reload:
none. The problem is when I go through this gui menu and click on the skull, only the part where it freezes the player runs, instead of toggling like I want it to. I have made a command to test to see that the variables were working, so that isnt the problem. Just dont understand why it only runs one part of the skript.


Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? I added the else part to see if the variables were the problem (they arent)
 
Try placing the
code_language.skript:
set {_p} to uncolored item's name parsed as player
at the top, so that the variable {_p} is set when you check for a variable with {_p} in it
 
Good news i found the problem.
code_language.skript:
  if inventory name of the player's current inventory is "&bFreeze":
        clicked item is head
        if {freeze.%{_p}%.frozen} is 0:
            set {_p} to uncolored item's name parsed as player
{_p} is not defined in the first variable. Thanks TPGames!
 
Status
Not open for further replies.