Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I need to make a randomized and rarity spawner but how do you add rarities?

Asked by 4 years ago

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.

1 answer

Log in to vote
0
Answered by 4 years ago

Use math.random() to generate random values. Based on these random values, give different items.

Ad

Answer this question