Solved Teleport player to {variable}

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

Kolombooo

Active Member
Dec 3, 2020
51
3
8
How to teleport player to coordinates in variable saved like this:
Code:
command /rtp:
  permission: rtp.use
  permission message: &7[&6&lCoud&e&lMC&7] &8No permission!
  trigger:
    message "&7[&6&lCoud&e&lMC&7] Teleporting..."
    set {%player%::rtpx} to random number between 0 and 20000
    message "DEBUG: X = %{%player%::rtpx}% "
    set {%player%::rtpy} to random number between 60 and 80
    message "DEBUG: Y = %{%player%::rtpy}% "
    set {%player%::rtpz} to random number between 0 and 20000
    message "DEBUG: Z = %{%player%::rtpz}% "
    execute console command "effect %player% resistance 10 255"
    teleport player to %{%player%::rtpx}%, %{%player%::rtpx}%, %{%player%::rtpz}%
 
First of all, let us know if you get any errors, second, try to set the variable to {%player%.rtpx(or y/z)} without the colon, third,
the expression "teleport player to" (line 13) is not correct, the correct one is "teleport player to location (x.x, y.x, z.x) (-.x means the decimal number like 2.4). Fourth, try to set the random number to an integer, like this: "set {blabla} to a random integer between 1 and 20".
Hope it helped!
 
First of all, let us know if you get any errors, second, try to set the variable to {%player%.rtpx(or y/z)} without the colon, third,
the expression "teleport player to" (line 13) is not correct, the correct one is "teleport player to location (x.x, y.x, z.x) (-.x means the decimal number like 2.4). Fourth, try to set the random number to an integer, like this: "set {blabla} to a random integer between 1 and 20".
Hope it helped!
Still not working. But thanks for help. Now the code is:
Code:
    teleport player to location (%{%player%::rtpx}%,  %{%player%::rtpy}%, %{%player%::rtpz}%)
 
Ok so, i tested it now and i fixed your error. Here is the code:
Code:
command /rtp:
  permission: rtp.use
  permission message: &7[&6&lCoud&e&lMC&7] &8No permission!
  trigger:
    message "&7[&6&lCoud&e&lMC&7] Teleporting..."
    set {%player%::rtpx} to random number between 0 and 20000
    message "DEBUG: X = %{%player%::rtpx}% "
    set {%player%::rtpy} to random number between 60 and 80
    message "DEBUG: Y = %{%player%::rtpy}% "
    set {%player%::rtpz} to random number between 0 and 20000
    message "DEBUG: Z = %{%player%::rtpz}% "
    execute console command "effect %player% resistance 10 255"
    teleport player to location ({%player%::rtpx}, {%player%::rtpy}, {%player%::rtpz})

Error = At the expression "teleport player to location (%{%player%::rtpx}%, %{%player%::rtpy}%, %{%player%::rtpz}%)" you had to remove the "%" before the brackets, so it would've looked like this:
Code:
teleport player to location ({%player%::rtpx}, {%player%::rtpy}, {%player%::rtpz})

Hope it helped you to understand your issue! Bye!
 
Ok so, i tested it now and i fixed your error. Here is the code:
Code:
command /rtp:
  permission: rtp.use
  permission message: &7[&6&lCoud&e&lMC&7] &8No permission!
  trigger:
    message "&7[&6&lCoud&e&lMC&7] Teleporting..."
    set {%player%::rtpx} to random number between 0 and 20000
    message "DEBUG: X = %{%player%::rtpx}% "
    set {%player%::rtpy} to random number between 60 and 80
    message "DEBUG: Y = %{%player%::rtpy}% "
    set {%player%::rtpz} to random number between 0 and 20000
    message "DEBUG: Z = %{%player%::rtpz}% "
    execute console command "effect %player% resistance 10 255"
    teleport player to location ({%player%::rtpx}, {%player%::rtpy}, {%player%::rtpz})

Error = At the expression "teleport player to location (%{%player%::rtpx}%, %{%player%::rtpy}%, %{%player%::rtpz}%)" you had to remove the "%" before the brackets, so it would've looked like this:
Code:
teleport player to location ({%player%::rtpx}, {%player%::rtpy}, {%player%::rtpz})

Hope it helped you to understand your issue! Bye!
Thanks so much for your help. You are so nice guy.
 
Status
Not open for further replies.