Pet Fusion Planner Module

A non-destructive Luau planner that groups eligible Studio pet records by species and rarity while protecting locked or mutated entries.

Roblox Studio ModuleScript

What this script does

Preview fusion groups from records you supply. The module returns plans only and never deletes, mutates, or saves a pet.

Best for
Designing a transparent pet fusion confirmation screen in your own experience.
Language
Luau
Version
1.0.0
Validation
Luau runtime tested
Luau runtime tested

Official Luau 0.735 parsing and strict analysis pass, and the module is covered by the pure-module runtime behavior harness.

Included behavior

  • Species and rarity grouping
  • Locked and mutated protection
  • Configurable keep count and group size

Install in the stated runtime

  1. 1
    Create a ModuleScript named FusionPlanner.
  2. 2
    Paste the complete source and require it from a server or test Script in your own experience.
  3. 3
    Show returned groups to the player and revalidate every selected id on the server before committing your own fusion.

Minimal usage example

local Planner = require(script.Parent.FusionPlanner)
local plans = Planner.plan(pets, 3, 1)
for _, group in plans do print("Possible group", #group) end

Example inputs and result

Supply
Your Pet records, requested group size, and number of copies to keep.
Expect
plan returns proposed groups only; it never consumes or saves a Pet.

These notes explain the example above. Read the complete source for every exported function and edge case before integrating it.

Complete source

No hidden import, minified block, or shortened loader.

--!strict
-- MIT License. Plans groups from your own pet records; it performs no deletion.

export type FusionPet = { id: string, species: string, rarity: string, mutation: string?, locked: boolean? }
local FusionPlanner = {}

function FusionPlanner.plan(pets: { FusionPet }, groupSize: number, keepPerGroup: number?): { { FusionPet } }
	assert(groupSize >= 2, "Fusion group size must be at least two")
	local grouped: { [string]: { FusionPet } } = {}
	for _, pet in pets do
		if not pet.locked and not pet.mutation then
			local key = pet.species .. "|" .. pet.rarity
			grouped[key] = grouped[key] or {}
			table.insert(grouped[key], table.clone(pet))
		end
	end
	local plans = {}
	local keep = math.max(0, math.floor(keepPerGroup or 0))
	for _, group in grouped do
		local usable = math.max(0, #group - keep)
		for startIndex = 1, usable - groupSize + 1, groupSize do
			local plan = {}
			for index = startIndex, startIndex + groupSize - 1 do table.insert(plan, group[index]) end
			table.insert(plans, plan)
		end
	end
	return plans
end

return table.freeze(FusionPlanner)
SHA-2560a602d1016e5ebf70aa7d5a762ced7445f053750eb504b25ca22d0fc456df9e9

Outside this script’s scope

  • Perform fusion automatically
  • Access another experience’s inventory

Found a problem or a better approach?

Tell us what failed, what you expected, and whether the issue happened in the Luau CLI or Roblox Studio. Suggestions for clearer types, safer server checks, or a more useful API are welcome.

Do not submit credentials, private project files, or account data.