Solved Getting the location of the block the player is looking at

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

fireyburst

Member
Apr 22, 2022
4
0
1
Hi, I was wondering how to get the location of the block the player is looking at. I constantly get the error "can't compare player with 'looking at loop block'." Is there a way to do this or do i need an addon? Heres my code:

Code:
loop all blocks in radius 10 around player:
    if player is looking at loop-block:
        set {rgloc1.%player%} to location of loop-block
        message "&aLocation set to &d%{rgloc1.%player%}%"
 
Use the expression Targeted block (https://skripthub.net/docs/?id=911)

You should use this to check the distance between the block and the player for better performance:
Code:
if distance between player's target block and player <= 10:
    set {rgloc1.%player%} to location of player's target block
 
Status
Not open for further replies.