local clickDetector = workspace.Part.ClickDetector

function onMouseClick()
	local Items = {
		{"Exotic",1}, -- {"Exotic",1}, (1%)
		{"Legand",3},-- {"Legand",3}, (3%)
		{"Rare",55},-- {"Rare",55}, (55%)
		{"Common",100},-- {"Common",100}, (100%)
	}
	local TotalWeight = 0

	for _,ItemData in pairs(Items) do
		TotalWeight = TotalWeight + ItemData[2]
	end

	local function chooseRandomItem()
		local Chance = math.random(1,TotalWeight)
		local Counter = 0
		for _,ItemData in pairs(Items) do
			Counter = Counter + ItemData[2]
			if Chance <= Counter then
				return ItemData[1]
			end
		end
	end

	for i=1,1 do
		print(chooseRandomItem()) 
		game.Workspace.Display.BillboardGui.TextLabel.Text = chooseRandomItem();
		
	end
	
	
	
end
clickDetector.MouseClick:connect(onMouseClick)

1 comment

0

They're two seperate function calls. If you want both to be the same value, assign the function call to a variable and use that variable for print and the GUI.