mobs keep spawning

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

ParFumat_

Member
Mar 15, 2024
4
0
1
18
why do zombies spawn after exiting/dying in region dungeon1?
this was not supposed to happen

on load:
loop all players:
set {dungeonscore::%loop-player's uuid%} to 0

on death of player:
kill all zombies where [region at victim is "dungeon1"]

on death of zombie:
if victim is in region "dungeon1":
if attacker's gamemode is not creative:
add 1 to {dungeonscore::%attacker's uuid%}
send action bar "&eScore: %{dungeonscore::%attacker's uuid%}%" to attacker
if {dungeonscore::%attacker's uuid%} is 120:
wait 10 ticks
spawn a zombie at location -16, -58, -187:
set displayname of entity to "&7Zombie King"
set max health of entity to 250
set health of entity to 250
set knockback resistance attribute of entity to 1
set helmet of entity to unbreakable golden helmet
set chestplate of entity to unbreakable golden chestplate
set leggings of entity to unbreakable golden leggings
set boots of entity to unbreakable golden boots
set tool of entity to unbreakable golden sword
set offhand tool of entity to unbreakable golden sword
else if {dungeonscore::%attacker's uuid%} is 20:
give chest named "&7Floor I Lootbox" with lore " " and "&fCOMMON" to attacker
teleport attacker to location -34, -60, -190
else:
set {_newHealth} to max health of the victim + 5
wait 25 ticks
spawn a zombie at location of the victim:
set max health of entity to {_newHealth}
set health of entity to {_newHealth}

on enter of region "dungeon1":
wait 15 ticks
spawn 10 zombies at player:
set displayname of entity to "&7Zombie"
set max health of entity to 50
set health of entity to 50
set knockback resistance attribute of entity to 0.05

on exit of region "dungeon1":
kill all zombies where [region at player is "dungeon1"]
set {dungeonscore::%player's uuid%} to 0
 
Because you aren't doing anything to prevent it? Whether the player has died or not it's still going to spawn them when they enter the region "dungeon1".
 
Because you aren't doing anything to prevent it? Whether the player has died or not it's still going to spawn them when they enter the region "dungeon1".
I want to make it so that if the player (leaves, dies or uses a command to teleport him from there) the zombies die and stop spawning, only if a player enters the region the zombies spawn
 
I can't really understand what your code is doing, can you provide it but with proper indention and in a code block
Code:
 Like this?
 
Code:
on load:
  loop all players:
    set {dungeonscore::%loop-player's uuid%} to 0

on death of player:
    kill all zombies where [region at victim is "dungeon1"]

on death of zombie:
  if victim is in region "dungeon1":
    if attacker's gamemode is not creative:
      add 1 to {dungeonscore::%attacker's uuid%}
      send action bar "&eScore: %{dungeonscore::%attacker's uuid%}%" to attacker
      if {dungeonscore::%attacker's uuid%} is 120:
        wait 10 ticks
        spawn a zombie at location -16, -58, -187:
          set displayname of entity to "&7Zombie King"
          set max health of entity to 250
          set health of entity to 250
          set knockback resistance attribute of entity to 1
          set helmet of entity to unbreakable golden helmet
          set chestplate of entity to unbreakable golden chestplate
          set leggings of entity to unbreakable golden leggings
          set boots of entity to unbreakable golden boots
          set tool of entity to unbreakable golden sword
          set offhand tool of entity to unbreakable golden sword
      else if {dungeonscore::%attacker's uuid%} is 20:
        give chest named "&7Floor I Lootbox" with lore " " and "&fCOMMON" to attacker
        teleport attacker to location -34, -60, -190
      else if last damage cause of victim is from player:
        set {_newHealth} to max health of the victim + 5
        wait 25 ticks
        spawn a zombie at location of the victim:
          set max health of entity to {_newHealth}
          set health of entity to {_newHealth}

on enter of region "dungeon1":
  wait 15 ticks
  spawn 10 zombies at player:
    set displayname of entity to "&7Zombie"
    set max health of entity to 50
    set health of entity to 50
    set knockback resistance attribute of entity to 0.05

on exit of region "dungeon1":
  kill all zombies where [region at player is "dungeon1"]
  set {dungeonscore::%player's uuid%} to 0
I can't really understand what your code is doing, can you provide it but with proper indention and in a code block
Code:
 Like this?
 
Code:
on load:
  loop all players:
    set {dungeonscore::%loop-player's uuid%} to 0

on death of player:
    kill all zombies where [region at victim is "dungeon1"]

on death of zombie:
  if victim is in region "dungeon1":
    if attacker's gamemode is not creative:
      add 1 to {dungeonscore::%attacker's uuid%}
      send action bar "&eScore: %{dungeonscore::%attacker's uuid%}%" to attacker
      if {dungeonscore::%attacker's uuid%} is 120:
        wait 10 ticks
        spawn a zombie at location -16, -58, -187:
          set displayname of entity to "&7Zombie King"
          set max health of entity to 250
          set health of entity to 250
          set knockback resistance attribute of entity to 1
          set helmet of entity to unbreakable golden helmet
          set chestplate of entity to unbreakable golden chestplate
          set leggings of entity to unbreakable golden leggings
          set boots of entity to unbreakable golden boots
          set tool of entity to unbreakable golden sword
          set offhand tool of entity to unbreakable golden sword
      else if {dungeonscore::%attacker's uuid%} is 20:
        give chest named "&7Floor I Lootbox" with lore " " and "&fCOMMON" to attacker
        teleport attacker to location -34, -60, -190
      else if last damage cause of victim is from player:
        set {_newHealth} to max health of the victim + 5
        wait 25 ticks
        spawn a zombie at location of the victim:
          set max health of entity to {_newHealth}
          set health of entity to {_newHealth}

on enter of region "dungeon1":
  wait 15 ticks
  spawn 10 zombies at player:
    set displayname of entity to "&7Zombie"
    set max health of entity to 50
    set health of entity to 50
    set knockback resistance attribute of entity to 0.05

on exit of region "dungeon1":
  kill all zombies where [region at player is "dungeon1"]
  set {dungeonscore::%player's uuid%} to 0
Yeah, you aren't doing anything to stop them from spawning. If the player's dungeon score is exactly 20 or exactly 120 a new zombie will spawn every time one dies within the region. They will also always spawn when you enter the region. When you die/exit the region it insta-kills them, yes, but nothing is stopping them from spawning again.
 
Yeah, you aren't doing anything to stop them from spawning. If the player's dungeon score is exactly 20 or exactly 120 a new zombie will spawn every time one dies within the region. They will also always spawn when you enter the region. When you die/exit the region it insta-kills them, yes, but nothing is stopping them from spawning again.
can you help me with this too?

at score 20, the player is teleported out of the region, but if the player kills a zombie before being teleported, the zombie spawns and stays there, I don't want it to be like that, I want it to stop respawning if there is no player in the region

Code:
on load:
  loop all players:
    set {dungeonscore::%loop-player's uuid%} to 0

on death of player:
    kill all zombies where [region at victim is "dungeon1"]

on death of zombie:
  if victim is in region "dungeon1":
    if attacker's gamemode is not creative:
      add 1 to {dungeonscore::%attacker's uuid%}
      send action bar "&eScore: %{dungeonscore::%attacker's uuid%}%" to attacker
      if {dungeonscore::%attacker's uuid%} is 120:
        wait 10 ticks
        spawn a zombie at location -16, -58, -187:
          set displayname of entity to "&7Zombie King"
          set max health of entity to 250
          set health of entity to 250
          set knockback resistance attribute of entity to 1
          set helmet of entity to unbreakable golden helmet
          set chestplate of entity to unbreakable golden chestplate
          set leggings of entity to unbreakable golden leggings
          set boots of entity to unbreakable golden boots
          set tool of entity to unbreakable golden sword
          set offhand tool of entity to unbreakable golden sword
      else if {dungeonscore::%attacker's uuid%} is 20:
        give chest named "&7Floor I Lootbox" with lore " " and "&fCOMMON" to attacker
        teleport attacker to location -34, -60, -190
      else if last damage cause of victim is attack:
        set {_newHealth} to max health of the victim + 5
        wait 15 ticks
        spawn a zombie at location of the victim:
          set max health of entity to {_newHealth}
          set health of entity to {_newHealth}

on enter of region "dungeon1":
  wait 15 ticks
  spawn 10 zombies at player:
    set displayname of entity to "&7Zombie"
    set max health of entity to 50
    set health of entity to 50
    set knockback resistance attribute of entity to 0.05

on exit of region "dungeon1":
  kill all zombies where [region at player is "dungeon1"]
  set {dungeonscore::%player's uuid%} to 0
 
You would solve this using
Python:
on spawn of zombie:
    "%region at event-entity%" contains "dungeon1"
    loop players:
        "%region at loop-player%" contains "dungeon1":
            send title "" to player
        else:
            cancel event