Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local abilityName = "RANDOM_SWORD_ABILITY" -- Name of the ability
- local activationKeyCode = KeyCode.Q -- Key to activate the ability (e.g., "Q")
- -- List of items to remove
- local itemsToRemove = {
- "wood_sword",
- "stone_sword",
- "iron_sword",
- "diamond_sword",
- "emerald_sword",
- "void_sword",
- "stone_dagger",
- "wood_dagger",
- "iron_dagger",
- "diamond_dagger",
- "mythic_dagger",
- "stone_scythe",
- "wood_scythe",
- "iron_scythe",
- "diamond_scythe",
- "mythic_scythe",
- "wood_great_hammer",
- "stone_great_hammer",
- "iron_great_hammer",
- "diamond_great_hammer",
- "mythic_great_hammer",
- "juggernaut_rage_blade",
- "rageblade",
- "ice_sword",
- "big_wood_sword",
- "mass_hammer",
- "twirlblade",
- "double_edge_sword",
- "light_sword",
- "infernal_saber",
- "laser_sword",
- "bacon_blade",
- "wood_gauntlets",
- "stone_gauntlets",
- "iron_gauntlets",
- "diamond_gauntlets",
- "mythic_gauntlets",
- }
- -- Function to remove items from the player's inventory
- local function removeItemsFromInventory(player)
- for _, itemType in pairs(itemsToRemove) do
- InventoryService.removeItemAmount(player, itemType, InventoryService.getAmount(player, itemType))
- end
- end
- -- List of swords to choose from
- local meleeWeapons = {
- "wood_sword",
- "stone_sword",
- "iron_sword",
- "diamond_sword",
- "emerald_sword",
- "void_sword",
- "stone_dagger",
- "wood_dagger",
- "iron_dagger",
- "diamond_dagger",
- "mythic_dagger",
- "stone_scythe",
- "wood_scythe",
- "iron_scythe",
- "diamond_scythe",
- "mythic_scythe",
- "wood_great_hammer",
- "stone_great_hammer",
- "iron_great_hammer",
- "diamond_great_hammer",
- "mythic_great_hammer",
- "juggernaut_rage_blade",
- "rageblade",
- "ice_sword",
- "big_wood_sword",
- "mass_hammer",
- "twirlblade",
- "double_edge_sword",
- "light_sword",
- "infernal_saber",
- "laser_sword",
- "bacon_blade",
- "wood_gauntlets",
- "stone_gauntlets",
- "iron_gauntlets",
- "diamond_gauntlets",
- "mythic_gauntlets",
- }
- -- Function to give the player a random sword
- local function giveRandomMelee(player)
- local chosen = meleeWeapons[math.random(1, #meleeWeapons)]
- InventoryService.giveItem(player, chosen, 1, true)
- MessageService.sendInfo(player, "You got " .. string.upper(chosen) .. "!")
- end
- -- Create the ability
- AbilityService.createAbility(abilityName, activationKeyCode, {
- maxProgress = 10, -- Maximum progress (1 in this case)
- progressPerUse = 1, -- Progress gained per use (1 in this case)
- })
- Events.UseAbility(function(event)
- -- First, remove the specified items
- removeItemsFromInventory(event.entity:getPlayer())
- -- Then give the player a random sword
- giveRandomMelee(event.entity:getPlayer())
- end)
- -- Enable the ability for all the players
- for _, player in pairs(PlayerService.getPlayers()) do
- AbilityService.enableAbility(player, abilityName)
- end
Add Comment
Please, Sign In to add comment