Cat_in_the_hat

Untitled

Nov 3rd, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | Gaming | 0 0
  1. local abilityName = "RANDOM_SWORD_ABILITY" -- Name of the ability
  2. local activationKeyCode = KeyCode.Q -- Key to activate the ability (e.g., "Q")
  3.  
  4. -- List of items to remove
  5. local itemsToRemove = {
  6. "wood_sword",
  7. "stone_sword",
  8. "iron_sword",
  9. "diamond_sword",
  10. "emerald_sword",
  11. "void_sword",
  12. "stone_dagger",
  13. "wood_dagger",
  14. "iron_dagger",
  15. "diamond_dagger",
  16. "mythic_dagger",
  17. "stone_scythe",
  18. "wood_scythe",
  19. "iron_scythe",
  20. "diamond_scythe",
  21. "mythic_scythe",
  22. "wood_great_hammer",
  23. "stone_great_hammer",
  24. "iron_great_hammer",
  25. "diamond_great_hammer",
  26. "mythic_great_hammer",
  27. "juggernaut_rage_blade",
  28. "rageblade",
  29. "ice_sword",
  30. "big_wood_sword",
  31. "mass_hammer",
  32. "twirlblade",
  33. "double_edge_sword",
  34. "light_sword",
  35. "infernal_saber",
  36. "laser_sword",
  37. "bacon_blade",
  38. "wood_gauntlets",
  39. "stone_gauntlets",
  40. "iron_gauntlets",
  41. "diamond_gauntlets",
  42. "mythic_gauntlets",
  43. }
  44.  
  45. -- Function to remove items from the player's inventory
  46. local function removeItemsFromInventory(player)
  47. for _, itemType in pairs(itemsToRemove) do
  48. InventoryService.removeItemAmount(player, itemType, InventoryService.getAmount(player, itemType))
  49. end
  50. end
  51.  
  52. -- List of swords to choose from
  53. local meleeWeapons = {
  54. "wood_sword",
  55. "stone_sword",
  56. "iron_sword",
  57. "diamond_sword",
  58. "emerald_sword",
  59. "void_sword",
  60. "stone_dagger",
  61. "wood_dagger",
  62. "iron_dagger",
  63. "diamond_dagger",
  64. "mythic_dagger",
  65. "stone_scythe",
  66. "wood_scythe",
  67. "iron_scythe",
  68. "diamond_scythe",
  69. "mythic_scythe",
  70. "wood_great_hammer",
  71. "stone_great_hammer",
  72. "iron_great_hammer",
  73. "diamond_great_hammer",
  74. "mythic_great_hammer",
  75. "juggernaut_rage_blade",
  76. "rageblade",
  77. "ice_sword",
  78. "big_wood_sword",
  79. "mass_hammer",
  80. "twirlblade",
  81. "double_edge_sword",
  82. "light_sword",
  83. "infernal_saber",
  84. "laser_sword",
  85. "bacon_blade",
  86. "wood_gauntlets",
  87. "stone_gauntlets",
  88. "iron_gauntlets",
  89. "diamond_gauntlets",
  90. "mythic_gauntlets",
  91. }
  92.  
  93. -- Function to give the player a random sword
  94. local function giveRandomMelee(player)
  95. local chosen = meleeWeapons[math.random(1, #meleeWeapons)]
  96. InventoryService.giveItem(player, chosen, 1, true)
  97. MessageService.sendInfo(player, "You got " .. string.upper(chosen) .. "!")
  98. end
  99.  
  100. -- Create the ability
  101. AbilityService.createAbility(abilityName, activationKeyCode, {
  102. maxProgress = 10, -- Maximum progress (1 in this case)
  103. progressPerUse = 1, -- Progress gained per use (1 in this case)
  104. })
  105.  
  106. Events.UseAbility(function(event)
  107. -- First, remove the specified items
  108. removeItemsFromInventory(event.entity:getPlayer())
  109. -- Then give the player a random sword
  110. giveRandomMelee(event.entity:getPlayer())
  111. end)
  112.  
  113. -- Enable the ability for all the players
  114. for _, player in pairs(PlayerService.getPlayers()) do
  115. AbilityService.enableAbility(player, abilityName)
  116. end
Add Comment
Please, Sign In to add comment