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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    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 Teleport player to {variable}

Discussion in 'Skript' started by Kolombooo, Mar 25, 2021.

Thread Status:
Not open for further replies.
  1. Kolombooo

    Kolombooo Active Member

    Joined:
    Dec 3, 2020
    Messages:
    51
    Likes Received:
    3
    How to teleport player to coordinates in variable saved like this:
    Code (Text):
    1. command /rtp:
    2.   permission: rtp.use
    3.   permission message: &7[&6&lCoud&e&lMC&7] &8No permission!
    4.   trigger:
    5.     message "&7[&6&lCoud&e&lMC&7] Teleporting..."
    6.     set {%player%::rtpx} to random number between 0 and 20000
    7.     message "DEBUG: X = %{%player%::rtpx}% "
    8.     set {%player%::rtpy} to random number between 60 and 80
    9.     message "DEBUG: Y = %{%player%::rtpy}% "
    10.     set {%player%::rtpz} to random number between 0 and 20000
    11.     message "DEBUG: Z = %{%player%::rtpz}% "
    12.     execute console command "effect %player% resistance 10 255"
    13.     teleport player to %{%player%::rtpx}%, %{%player%::rtpx}%, %{%player%::rtpz}%


     
  2. Best Answer:
    Post #4 by Turb032, Mar 25, 2021
  3. Turb032

    Turb032 Active Member

    Joined:
    Jan 16, 2020
    Messages:
    109
    Likes Received:
    0
    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!
     
  4. Kolombooo

    Kolombooo Active Member

    Joined:
    Dec 3, 2020
    Messages:
    51
    Likes Received:
    3
    Still not working. But thanks for help. Now the code is:
    Code (Text):
    1.     teleport player to location (%{%player%::rtpx}%,  %{%player%::rtpy}%, %{%player%::rtpz}%)
     
  5. Turb032

    Turb032 Active Member

    Joined:
    Jan 16, 2020
    Messages:
    109
    Likes Received:
    0
    Ok so, i tested it now and i fixed your error. Here is the code:
    Code (Text):
    1. command /rtp:
    2.   permission: rtp.use
    3.   permission message: &7[&6&lCoud&e&lMC&7] &8No permission!
    4.   trigger:
    5.     message "&7[&6&lCoud&e&lMC&7] Teleporting..."
    6.     set {%player%::rtpx} to random number between 0 and 20000
    7.     message "DEBUG: X = %{%player%::rtpx}% "
    8.     set {%player%::rtpy} to random number between 60 and 80
    9.     message "DEBUG: Y = %{%player%::rtpy}% "
    10.     set {%player%::rtpz} to random number between 0 and 20000
    11.     message "DEBUG: Z = %{%player%::rtpz}% "
    12.     execute console command "effect %player% resistance 10 255"
    13.     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 (Text):
    1. teleport player to location ({%player%::rtpx}, {%player%::rtpy}, {%player%::rtpz})
    Hope it helped you to understand your issue! Bye!
     
  6. Kolombooo

    Kolombooo Active Member

    Joined:
    Dec 3, 2020
    Messages:
    51
    Likes Received:
    3
    Thanks so much for your help. You are so nice guy.
     
  7. Turb032

    Turb032 Active Member

    Joined:
    Jan 16, 2020
    Messages:
    109
    Likes Received:
    0
    Thanks :emoji_blush:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...