Solved random block in radius

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

loadka95

Active Member
Feb 24, 2017
78
6
8
i want to put down a random block around the {_random} location in 3 radius, but when i run the command its set the {_random} variable to <none>, but i have no idea why..


code_language.skript:
                        set x-coordinate of {_random} to x-coordinate of {_random} + a random integer between -3 and 3
                        set z-coordinate of {_random} to z-coordinate of {_random} + a random integer between -3 and 3
                        set block at {_random} to stone
                        broadcast "%{_random}%"
 
Try this:

code_language.skript:
loop all blocks in radius 3 around player:
    add 1 to {_x}
set {_x} to random integer between 1 and {_x}
loop all blocks in radius 3 around player:
    add 1 to {_y}
    {_x} is {_y}
    set {_random} to location of loop-block
    exit loop
set block at {_random} to stone
broadcast "%{_random}%"
 
Just set a variable to the exact location:
code_language.skript:
set {_x} to {_random}'s x-pos + random integer from -3 to 3
set {_z} to {_random}' z-pos + random ineger from -3 to 3
set {_random} to location({_x}, {_random}'s y-pos, {_z}. {_random}'s world)
set block at {_random} to stone
 
  • Like
Reactions: loadka95
Status
Not open for further replies.