Docs / Roblox Games/Grow a Bunny

Grow a Bunny

Simulator where players grow, care for, and sell bunnies.

Roblox GamesLuaProfileServicePlotting SystemSimulator
Grow a Bunny

Overview

In Grow a Bunny, players are assigned to their own farm, where they grow and hatch bunnies, which they then collect and sell to purchase better bunny eggs. The bunnies in the game have a random weight assigned to them, which determines the price of the bunny. The bunnies can also have various rarities, which determine their price as well. The game offers a rotating shop, which stocks up on random items ever 5 minutes for players to purchase.

Key Systems & Features

  • Custom plot system
  • Rotating shop
  • Custom dialogue system
  • Dynamic robux shop

Code Examples

Below are some code snippets from this project.

Plant data grabbing
LUA
function Planting.GrabPlanterData(player: Player)
	local plot = getPlayerPlot(player)
	if not plot then return {} end

	local data          = {}
	local plantedFolder = plot:FindFirstChild("PlantedItems")
	if not plantedFolder then return data end

	for _, item in ipairs(plantedFolder:GetChildren()) do
		if item:IsA("BasePart") or item:IsA("Model") then
			local planterName  = item:GetAttribute("Planter")
			local planterModel = planterName and plot:FindFirstChild(planterName)
			local plantables   = planterModel and planterModel:FindFirstChild("Plantables")

			if plantables and plantables:IsA("BasePart") then
				-- local CFrame (position + rotation) relative to Plantables
				local localCF = plantables.CFrame:ToObjectSpace(item.CFrame)

				table.insert(data, {
					ItemName    = item:GetAttribute("ItemName"),
					Planter     = planterName,
					LocalCF     = {localCF:GetComponents()},   -- 12 numbers
					IsGrown     = item:GetAttribute("Grown"),
					CurrentTime = item:GetAttribute("CurrentTime") or 0,
					LastUpdated = os.time(),
					Enchanted   = item:GetAttribute("Enchanted") or false,
				})
			end
		end
	end

	return data
end
Bunny tool creation
LUA
local function createBunnyTool(player: Player, scriptName: string, weight: number, enchanted: boolean, amount: number)
	local data = getDataByScriptName(scriptName)
	if not data then return end

	-- base Tool template comes from ReplicatedStorage
	local tool = ReplicatedStorage:WaitForChild("Tools"):WaitForChild("BunnyTool"):Clone()
	tool:SetAttribute("Amount", amount or 1)
	tool:SetAttribute("Weight", weight)
	tool:SetAttribute("EggName", scriptName)
	tool:SetAttribute("Type", "Bunny")
	tool:SetAttribute("Enchanted", enchanted)
	tool.Name = string.format("%s %.2fkg x%d", scriptName, weight, amount)

	-- model visual
	local modelClone = data.ModelPath:Clone()
	WeldModelParts(modelClone)

	local handle = modelClone:FindFirstChild("Main")
	if not handle or not handle:IsA("BasePart") then
		warn("Handle missing on model for", scriptName)
		modelClone:Destroy()
	else
		handle.Name       = "Handle"
		handle.Anchored   = false
		modelClone.Name   = "Model"

		if enchanted then
			local sparkles   = Instance.new("Sparkles")
			sparkles.Name    = "EnchantSparkles"
			sparkles.Parent  = handle
		end

		modelClone.Parent = tool
		handle.Parent     = tool
	end

	tool.Parent = player.Backpack
	return tool
end

Links