I am trying to make a game, like when you die, you spawn with a different item each time. I want it to have rarities, like common, uncommon, etc... Or like 50%, 25% etc... But unfortunately, I only have this code.
function died(deadplayer) end game.Players.ChildAdded:connect(function(newPlayer) newPlayer.CharacterAdded:connect(function(newCharacter) local Backpack = newPlayer.Backpack wait(0.01) newCharacter.Humanoid.Died:connect(function() died(newCharacter) end) game.ReplicatedStorage.Tools.Common.ClassicSword:Clone().Parent = Backpack end) end)
There are 5 rarites in the ReplicatedStorage, and This script is in the ServerScriptService.
This script is a Script, not a LocalScript.
I need to make it randomized and also add rarities.
Use math.random()
to generate random values. Based on these random values, give different items.