So I want to make a boss battle system. When the boss is killed by a player, the boss will give a random item drop. But what I want is to add a rarity to the drop. For an example, the boss will drop 2 items, a part and a sword. The part has 50% chance of being dropped and the sword is 20%. This means when you killed the boss, they can drop the part, or the sword, or both, or even nothing. So the boss will not always drop something everytime they got killed. Any idea how to make that?
1 Like
if math.random(1, 2) == 2 then -- 1, 2 chance = 50%
part.Parent = player.Backpack
end
if math.random(1, 5) == 5 then -- 1, 5 chance = 20%
sword.Parent = player.Backpack
end
1 Like
I think this is what you’re looking for
local bossDrops = {
Part = 50,
Sword = 20
}
for i,v in next, bossDrops do
local randomNumber = math.random(100)
if randomNumber <= v then
print(i)--//you'd need to have a folder of item drops or just add it to their data, example
--[[
local itemFolder = game:GetService("ServerStorage").ItemDrops
local bossDrops = {
itemFolder["Part"] = 50,
itemFolder["Sword"] = 20
}
and then clone that drop and put it in their inventory
]]
end
end
2 Likes