Compass tracker skript

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

rilasiggs

Member
Aug 10, 2020
4
0
0
23
So I am making a skript that tracks a player when the compass is right clicked, and I am having trouble with the conditional in the skript.
Code:
command /track <player>:                                       
  description: Use this command to track a player by right clicking with a compass
  trigger:                                               
    set {target player} to  arg 1                               
    send "<yellow>You are tracking %{target player}%"               
    give compass to the player

on rightclick with a compass:
  if player and {targetplayer} is in world "world":                           
    set {track location} to location of {target player}                           
    set player's compass target to {track location}
    send "<light green>Compass is now pointing to %{target player}%"
  else if player is in world "world":
    send "<light red>%{target player}%<light red> is not in the Overworld"
  else:
    send "<light red>The compass does not work in this dimension"

When I test the skirpt on my server, the game says *player name* is not in the Overworld, so clearly the first conditional is not including all the scenarios I want it to. When the compass is used in the other dimensions, the correct text appears, therefore (if I'm correct) the problem is line 9:
"if player and {targetplayer} is in world "world"
(this line is meant to check if both the tracked player and the player with the compass are in the overworld)
Any suggestions on what to change?
 
try with this:
Code:
command /track <player>:                                     
  description: Use this command to track a player by right clicking with a compass
  trigger:                                             
    set {target::%arg 1%::*} to arg 1                             
    send "<yellow>You are tracking %{target::%arg 1%::*}%"             
    give compass to the player
 
on rightclick with a compass:
  if player and {target::%arg 1%::*} is in world "world":                         
    set {track.location} to location of {target::%arg 1%::*}                         
    set player's compass target to {track.location}
    send "<light green>Compass is now pointing to %{target::%arg 1%::*}%"
  else if {target::%arg 1%::*} is in world "world":
    send "<light red>%{target::%arg 1%::*}%<light red> is not in the Overworld"
  else:
    send "<light red>The compass does not work in this dimension."
 
try with this:
Code:
command /track <player>:                                     
  description: Use this command to track a player by right clicking with a compass
  trigger:                                            
    set {target::%arg 1%::*} to arg 1                            
    send "<yellow>You are tracking %{target::%arg 1%::*}%"            
    give compass to the player
 
on rightclick with a compass:
  if player and {target::%arg 1%::*} is in world "world":                        
    set {track.location} to location of {target::%arg 1%::*}                        
    set player's compass target to {track.location}
    send "<light green>Compass is now pointing to %{target::%arg 1%::*}%"
  else if {target::%arg 1%::*} is in world "world":
    send "<light red>%{target::%arg 1%::*}%<light red> is not in the Overworld"
  else:
    send "<light red>The compass does not work in this dimension."
Sorry for the late reply. Here is the error message I got.
error.png

[doublepost=1597432536,1597421810][/doublepost]Never mind, I had a typo in my original code, line 9 had a typo in the variable.
 
Status
Not open for further replies.