Trying to make dice, need some help

The function returns a normalId, which you can do what I did for chosing a minigame.


local function FindUpSurface(part)
	local surface
	local max_height = -math.huge

	for i, enum in pairs(Enum.NormalId:GetEnumItems()) do
		local enum_height = (part.CFrame*CFrame.new(Vector3.FromNormalId(enum))).Y   -- find the y position in world space of the part's surface
		if enum_height > max_height then   -- if it's higher than the previous ones then it's more up!
			max_height = enum_height
			surface = enum
		end
	end

	return surface
end

local minigames = ... -- a list of your minigames
local randomMinigames = {}
for i = 1, 6 do -- has a random minigame for each side of the die
	local minigame = minigames[Random.new():NextInteger(1, #minigames)] -- a random number selector, like math.random but more random.
	table.insert(randomMinigames, minigame)
end
local die = ... -- path to die (singular for dice)
local velocity = Random.new():NextInteger(100, 200)
die.Velocity = Vector3.new(0, velocity, 0)
repeat wait(1) until die.Velocity.Magnitude == 0 and die.RotVelocity.Magnitude == 0 -- wait until die stops
FindUpSurface(die) -- The function you were given
print(surface) -- returns a normalid (https://developer.roblox.com/en-us/api-reference/enum/NormalId)
-- im pretty sure you can do the surfacenormal value to chose a random one
local finalMinigame = randomMinigames[surface.Value] -- the chosen minigame

If your minigames table is a dictionary, then you should add them to an array.

local minigames = {} -- a fake minigames list for selecting a minigame
for _, data in pairs(realMinigames) do -- the table you actually use
	 table.insert(minigames, data)
end
3 Likes