1. 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!


    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Trying to find the location of a command sender that is a command block.

Discussion in 'Skript' started by 02skaplan, Nov 2, 2020.

Thread Status:
Not open for further replies.
  1. 02skaplan

    02skaplan Member

    Nov 2, 2020
    Likes Received:
    Script Version (do not put latest): 2.5.1
    Script Author: SkriptLang
    Minecraft Version: 1.12.2
    Full Code:

    Code (Text):
    1. command /test:
    2.     trigger:
    3.         loop all entities in radius 5 around block's location:
    4.             loop-entity is a player:
    5.                 message "%block's location%" to loop-entity

    Errors on Reload:
    There's no block in a command event (line 3).

    Console Errors: (if applicable)

    Other Useful Info:
    I'm new to Skript.
    Executing /test in command block. The documentation says that
    "If the command sender is a command block, its location can be retrieved by using %block's location%."

    Addons using (including versions):

    Changing syntax from "command sender" to "command executor", adding 5th line to check block's location, which comes back <none>.

    Changing code to:
    Code (Text):
    1. command /test:
    2.     trigger:
    3.         loop all entities:
    4.             loop-entity is a player:
    5.                 message "%command executor's location%" to loop-entity
    Yields "<none>" being sent to the player. I'm looking for the command block's location.

    Have you tried searching the docs? Yes, see Other Useful Info.
    Have you tried searching the Forums? Yes, I found this old post which seemed to have the same issue, but a fix was never mentioned.
    What other methods have you tried to fix it?
    See Troubleshooting

    Thank you in advance to anyone who tries to help!
    --- Double Post Merged, Nov 3, 2020, Original Post Date: Nov 2, 2020 ---
    Thanks to the help of some kind samaritans on the Discord, I have found a working solution. The correct code for this situation is:
    Code (Text):
    1. command sender.getBlock().getLocation()
    Thank you to Killerz1243, DelayedGaming, and TheRealUnderscore for their help on this one. The full code in working condition is:
    Code (Text):
    2. command /test:
    3.     trigger:
    4.         set {_location} to command sender.getBlock().getLocation()
    5.         loop all entities in radius 5 of {_location}:
    6.             loop-entity is a player:
    7.                 message "%command sender.getBlock().getLocation()%" to loop-entity
    I also had to install Skript-Reflect in order for this to work.
    #1 02skaplan, Nov 3, 2020
    Last edited: Nov 3, 2020
  2. novastosha

    novastosha Well-Known Member

    Jan 11, 2019
    Likes Received:
    LOL. use Java make your life easier
Thread Status:
Not open for further replies.

Share This Page