Advertisement
Cat_in_the_hat

Spawn kit type on a block of your liking change wool_white on what blocks they spawn on

Dec 6th, 2023
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1.  
  2.  
  3. local speed = 30
  4. local attackDistance = 25
  5. local damageAmount = 17.5
  6. local customMaxHealth = 100
  7. local spawnWaitTime = 20
  8. local customHandItem = ItemType.SKY_SCYTHE
  9. local customKitType = KitType.FROSTY
  10. local damageMultiplier = 20
  11.  
  12. local hitSound = SoundType.PENGUIN_ATTACK_3
  13. local spawnSound = SoundType.WIZARD_LIGHTNING_CAST
  14.  
  15. Events.EntityDamage(function(event)
  16. event.knockback.horizontal = 0
  17. event.knockback.vertical = 0
  18.  
  19. local kit = event.entity
  20. local kitHealth = kit:getHealth()
  21. local halfHealth = customMaxHealth / 2
  22.  
  23. if kitHealth == halfHealth then
  24. event.damage = event.damage * damageMultiplier
  25. end
  26.  
  27. SoundService.playSound(hitSound, kit:getPosition())
  28. end)
  29.  
  30. while true do
  31. local pos = BlockService.getAboveRandomBlock({"wool_white"}) -- Updated block type
  32.  
  33. if not pos then
  34. error("No wool_white block found!") -- Updated error message
  35. end
  36.  
  37. pos = Vector3.new(pos.X, pos.Y + 10, pos.Z)
  38.  
  39. SoundService.playSound(spawnSound, pos)
  40.  
  41. local kit = EntityService.spawnKitEntity(customKitType, pos)
  42. kit:setMaxHealth(customMaxHealth)
  43. kit:setHandItem(customHandItem)
  44. kit:setSpeed(speed)
  45.  
  46. task.spawn(function()
  47. while true do
  48. local players = PlayerService.getPlayers()
  49.  
  50. if #players > 0 then
  51. local randomPlayer = players[math.random(#players)]
  52.  
  53. if randomPlayer then
  54. local playerPos = randomPlayer:getEntity():getPosition()
  55. kit:setPosition(playerPos)
  56. kit:moveTo(playerPos)
  57.  
  58. local kitPos = kit:getPosition()
  59. local distance = (playerPos - kitPos).Magnitude
  60.  
  61. if distance <= attackDistance then
  62. CombatService.damage(randomPlayer:getEntity(), damageAmount, {
  63. horizontal = 0,
  64. vertical = 0,
  65. fromPosition = playerPos
  66. })
  67. task.wait(0.0000001)
  68. end
  69. end
  70. end
  71.  
  72. task.wait(1)
  73. end
  74. end)
  75.  
  76. task.wait(spawnWaitTime)
  77. end
  78.  
  79. print("Script has worked! Made by Cat in the Hat!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement