Hello! I need help with ‘random.math’, I need to make the list called ‘Eggs’ the legendary has a 5% chance to appear, epic 15%, rare 30%, and common 50% and then print the chosen one with its value on screen , How can I do that?
Script code:
-- Eggs types:
local legendary = script.Parent["Legendary blue"]
local epic = script.Parent["Epic red"]
local rare = script.Parent["Rare brown"]
local common = script.Parent["Common green"]
-- Eggs list:
local Eggs = {legendary = 5, epic = 15, rare = 30, common = 50}
-- Code
local Player = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
local PlayerCharacter = Player:GetPlayerFromCharacter(hit.Parent)
if PlayerCharacter then
local Leaderstats = PlayerCharacter:WaitForChild("leaderstats")
Leaderstats.Cash.Value = Leaderstats.Cash.Value - 10
math.random(Eggs)
print ("the random math value is: "..Eggs)
end
end)