Advertisement
Cat_in_the_hat

Spawn snow man’s in waves

Dec 6th, 2023 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. -- The parameters for frosty waves
  2. local initialBatchSize = 10
  3. local batchSize = initialBatchSize
  4. local speed = 30
  5. local attackDistance = 25
  6. local damageAmount = 15
  7. local customMaxHealth = 100
  8. local customHandItem = ItemType.SKY_SCYTHE
  9. local customKitType = KitType.FROSTY
  10. local damageMultiplier = 5
  11. local waitBeforeStartEachWave = 10 -- Adjust this value for the desired wait time per wave
  12. local additionalFrostiesPerWave = 3 -- Adjust this value for the number of additional Frosties per wave
  13. local hitSound = SoundType.PENGUIN_ATTACK_3
  14. local spawnSound = SoundType.WIZARD_LIGHTNING_CAST
  15.  
  16. local function waitBeforeNextWave(seconds)
  17. local remainingTime = seconds
  18. while remainingTime > 0 do
  19. AnnouncementService.sendAnnouncement("Next wave in " .. math.floor(remainingTime) .. " seconds.", Color3.fromRGB(0, 128, 255))
  20. remainingTime = remainingTime - 1
  21. task.wait(1)
  22. end
  23. end
  24.  
  25. local function addMorePerWave()
  26. batchSize = batchSize + additionalFrostiesPerWave
  27. end
  28.  
  29. local function spawnFrosties()
  30. local currentWave = 1
  31.  
  32. while true do
  33. -- Get all grass blocks
  34. local grassBlocks = BlockService.getAboveRandomBlock({"grass"})
  35.  
  36. if not grassBlocks then
  37. error("No grass block found!")
  38. end
  39.  
  40. local basePosition = Vector3.new(grassBlocks.X, grassBlocks.Y + 5, grassBlocks.Z)
  41.  
  42. local frostiesAlive = 0
  43. local isWaveAnnounced = false
  44. local isTimerAnnounced = false
  45.  
  46. for i = 1, batchSize do
  47. local offset = Vector3.new(math.random(-5, 5), 0, math.random(-5, 5))
  48. local position = basePosition + offset
  49.  
  50. local frosty = EntityService.spawnKitEntity(customKitType, position)
  51. frosty:setMaxHealth(customMaxHealth)
  52. frosty:setHandItem(customHandItem)
  53. frosty:setSpeed(speed)
  54.  
  55. task.spawn(function()
  56. while frosty:isAlive() do
  57. local players = PlayerService.getPlayers()
  58.  
  59. if #players > 0 then
  60. local randomPlayer = players[math.random(#players)]
  61.  
  62. if randomPlayer then
  63. local playerPos = randomPlayer:getEntity():getPosition()
  64. frosty:setPosition(playerPos)
  65. frosty:moveTo(playerPos)
  66.  
  67. local frostyPos = frosty:getPosition()
  68. local distance = (playerPos - frostyPos).Magnitude
  69.  
  70. if distance <= attackDistance then
  71. CombatService.damage(randomPlayer:getEntity(), damageAmount, {
  72. horizontal = 0,
  73. vertical = 0,
  74. fromPosition = playerPos
  75. })
  76. task.wait(0.0000001)
  77. end
  78. end
  79. end
  80.  
  81. task.wait(1)
  82. end
  83.  
  84. frostiesAlive = frostiesAlive - 1
  85. end)
  86.  
  87. frostiesAlive = frostiesAlive + 1
  88. end
  89.  
  90. if not isWaveAnnounced then
  91. AnnouncementService.sendAnnouncement("Round " .. currentWave .. " has begun!", Color3.fromRGB(0, 128, 255))
  92. isWaveAnnounced = true
  93. end
  94.  
  95. if currentWave > 1 then
  96. if not isTimerAnnounced then
  97. while frostiesAlive > 3 do
  98. task.wait(1)
  99. end
  100.  
  101. AnnouncementService.sendAnnouncement("Next wave in " .. waitBeforeStartEachWave .. " seconds.", Color3.fromRGB(0, 128, 255))
  102. task.wait(waitBeforeStartEachWave)
  103. isTimerAnnounced = true
  104. end
  105. end
  106.  
  107. currentWave = currentWave + 1
  108. end
  109. end
  110.  
  111. -- Start spawning frosties immediately
  112. spawnFrosties()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement