# Random TP Skript help!!!

#### cns4646

##### Member
Code:
``````command /rtp:
trigger:
set {_x} to random integer between -100 and 100
set {_z} to random integer between -100 and 100
set {_y} to random integer between 5 and 150
set {_loc} to location({_x},{_y},{_z})
teleport player to {_loc}
loop 150 times:
if block at {_loc} is not air:
set {_loc} to location at {_x}, {_y}, {_z}
teleport player to {_loc}
stop
else:
subtract 1 from {_y}
set {_loc} to location at {_x}, {_y}, {_z}
loop 150 times:
if block at {_loc} is dirt or grass_block or bedrock:
else:
stop loop``````

I don't want to teleport on dirt, grass_block and bedrock

and

I want to make it possible to teleport between floors in the building, but I always go to the rooftop. What should I do

What is the point of travelling between floors in a building?

There are tons of problems with this code though.
Code:
``set {_loc} to location({_x},{_y},{_z})``
location is not a function. Just do "teleport player to {_x} {_y} {_z} in world "world""
Code:
``if block at {_loc} is dirt or grass_block or bedrock:``
the _ in grass_block is not needed, it's just grass block and don't use "or" more than once because it just gets messy.

Also why are you looping 150 times?

Code:
``````command /rtp:
trigger:
set {_x} to random integer between -100 and 100
set {_z} to random integer between -100 and 100
set {_y} to random integer between 5 and 150
if block at "{_x} {_y} {_z}" is air:
if block below "{_x} {_y} {_z}" is grass block:
teleport player to {_x} {_y} {_z} in world "world"
else:
make player execute command "/rtp"
else:
make player execute command "/rtp"``````

simple RTP command just there if u want to test it. I wrote this in class so it might not work.

Thank you for your response, I tried putting in the last code, but I got an error on numbers 6 and 11.

Line 6: "{_X}, {_Y}, {_Z}" is not alocation
Line 11: "else" has to be placed just after another 'if' or 'else if' section.

I didn't know the script, so I made some copies on YouTube

Ok I always have problems with teleporting. For line 11, try changing "else" to "if block at {_x} {_y} {_z} is not air:".

For the teleport bit on line 6, try doing
Code:
``````teleport player to {_x}, {_y}, {_z} in world "WORLD NAME"
#OR
make server execute command "/tp %player% {_x} {_y} {z}"``````

If this doesnt work then Im sorry but i dont think i can help