function Roll(Z)local R=0 for Z,c in pairs(Z)do R+=c end local c=table.clone(Z)for Z,k in pairs(c)do c[Z]=R/(100/k)end task.wait()local k=math.random(R)for Z,R in pairs(c)do local u=Z local x,I=R,0 for c,k in pairs(c)do if k<R then x+=k I+=k elseif k==R and c~=Z then x+=k local Z=math.random(1,2)if Z>1 then u=c end end end if k>I and k<=x then return u end end end


function Roll(Chances)
	local summary = 0

	for index, chance in pairs(Chances) do
		summary += chance
	end

	local NewChances = table.clone(Chances)

	for index, Chance in pairs(NewChances) do
		NewChances[index] = summary / (100 / Chance)
	end

	task.wait()

	local RandomNumber = math.random(summary)

	for index, chance in pairs(NewChances) do

		local Result = index

		local StartPoint, EndPoint = chance, 0

		for NextIndex, NextChance in pairs(NewChances) do
			if NextChance < chance  then
				StartPoint += NextChance; EndPoint += NextChance
			elseif NextChance == chance and NextIndex ~= index then
				StartPoint += NextChance

				local Set = math.random(1,2)

				if Set > 1 then
					Result = NextIndex
				end	
			end
		end

		if RandomNumber > EndPoint and RandomNumber <= StartPoint then

			return Result

		end

	end

end
