Mobs spawn near player every 10 seconds

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

donPaolo43

Member
Sep 14, 2025
1
0
1
JavaScript:
every 10 seconds:
 loop all players:
  chance of 80%:
   loop all monsters in radius 15 of loop-player:
    add loop-monster to {_monsters::*}
   if size of {_monsters::*} > 4 <=50:
    if time in world "world" is night:
     loop all blocks in radius 10 of loop-player:
      if loop-block is air:
       if block above loop-block is air:
        add loop-block's location to {_locs::*}
        if {_recentpatrol::*} contains loop-player's uuid:
         stop
        else:
         set {_spawn} to a random element out of {_locs::*}
         play sound "minecraft:block.trial_spawner.spawn_mob" with volume 1 at {_spawn}
         play 1 explosion emitter at {_spawn}
         chance of 30%:
          spawn zombie at {_spawn}
         chance of 30%:
          spawn skeleton at {_spawn}
         chance of 30%:
          spawn spider at {_spawn}
         chance of 30%:
          spawn creeper at {_spawn}
         add loop-player's uuid to {_recentpatrol::*}
         delete {_spawn}
         wait 60 seconds
         remove loop-player's uuid from {_recentpatrol::*}
I am trying to make a script that attempts to spawn a group of monsters near the player every 10 seconds, and if it succeeds it should put the player on a wait list for 60 seconds before running again. It also shoul only run if the monsters around the player are between 5 to 50.
It doesn't work like i want it to, at the beginning it just wouldn't start, then the spawn position {_spawn} wouldn't be deleted after the mobs spawning and they would just keep spawning in the same spot every 10 seconds ignoring the wait time.
I already rewrote the whole script 2 or 3 times and I can't understand what I'm doing wrong.
I should add that I learnt skript all by myself and I'm pretty sure there are many things I'm doing wrong and many that I could improve so any suggestion is well accepted.
 
does anyone know how to fix this:

JavaScript:
function generateBanID() :: text:
    set {_id} to random integer between 1 and 2
    if {_id} is in {blocked::id::*}:
        return "ERROR"
    else:
        add {_id} to {blocked::id::*}
        return "%{_id}%"
 
does anyone know how to fix this:

JavaScript:
function generateBanID() :: text:
    set {_id} to random integer between 1 and 2
    if {_id} is in {blocked::id::*}:
        return "ERROR"
    else:
        add {_id} to {blocked::id::*}
        return "%{_id}%"
Please open a new thread next time, you can fix this by using the contains condition instead of "is in".
Replace
Code:
if {_id} is in {blocked::id::*}:
with
Code:
if {blocked::id::*} contains {_id}: