How to make a Simple Egg Hunt Experience

Hey creators!

Today it’s almost Easter! So today I decided to make a simple tutorial to teach you to make a simple egg hunt game!

1. :egg:Make a new template or open the game :egg:

First start off by creating a new template.

2.:egg: Make the egg spawner.:egg:

To make a egg spawner, start by creating a new part. Make sure to put the part high up in the air, set Anchored to true and CanCollide to false so the eggs will drop down from the sky. But, you can put the spawner wherever you want, it doesn’t really matter.

3. :egg:Get/Make the eggs.:egg:

Next, you need to make the eggs. You could get the eggs in the toolbox if you want. Also, make sure the egg isn’t Anchored. Once you have the eggs, make a folder in ServerStorage, name the folder “Drop Eggs” and put all the eggs in the folder.

4. :egg:Get/Make hats for your eggs.:egg:

Next, you need to make the hats for your eggs by making a new instance called “Accessory.” Name the part of the hat “Handle” and the name of the Accessory be the egg’s name so the hat can be picked up. And make a new “Attachment” so the hat will stick to your avatar’s head. Also, make sure the hat isn’t Anchored. You could get the hats in the toolbox if you want. Once you have the hats, make another folder in ServerStorage, name the folder “EggHats” and put all the eggs in the folder.

5. :egg:Coding the spawner.:egg:

Finally, we will be coding the egg spawner. Make a script in inside of your spawner.

First, start by making the variables.

local Part = script.Parent
local Eggs = game:GetService("ServerStorage"):WaitForChild("Drop Eggs"):GetChildren()
local EggHats = game:GetService("ServerStorage"):WaitForChild("EggHats")
local Debris = game:GetService("Debris") 

Next, make the loop.

while wait(1) do  --- How long it takes to make a new egg
---- makes the eggs
end

Then, create a clone of an random selected egg

while wait(1) do
	local X = math.random(-1000,1000) -- creates a random x axis position for the eggs
	local Z = math.random(-1000,1000) -- creates a random y axis position for the eggs

	local EggClone = Eggs[math.random(1, #Eggs)]:Clone() --- Finds a new random egg from the egg folder
	EggClone.Position = Part.Position + Vector3.new(X,0,Z)
	EggClone.Parent = workspace -- puts the egg in workspace 
	Debris:AddItem(EggClone,50) -- How long the eggs will last before it despawns
	print("Egg Cloned")
	print(EggClone.Name)
end

Then, add special effects to the eggs.

EggClone.Touched:Connect(function(hit) --- When the egg is touched by an object
		if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("Humanoid") then
			print("Got Egg "..EggClone.Name.."")
			if EggClone.Name ==  ("Your egg's name")  then
				--- Effect
			end
			local Hat = EggHats:FindFirstChild(EggClone.Name)
			for _,v in pairs(hit.Parent:GetChildren()) do
				if v:IsA("Accessory") then
					v:Destroy() -- Removes the Accessories from the player so the egg is visible
				end
			end
			Hat:Clone().Parent = hit.Parent --- Adds egg to the avatar
			EggClone:Destroy() -- Destroys the egg
		end
	end)

Finally, your code should look like this.

local Part = script.Parent
local Eggs = game:GetService("ServerStorage"):WaitForChild("Drop Eggs"):GetChildren()
local EggHats = game:GetService("ServerStorage"):WaitForChild("EggHats")
local Debris = game:GetService("Debris") 

while wait(1) do  --- How long it takes to make a new egg
    local X = math.random(-1000,1000) -- creates a random x axis position for the eggs
	local Z = math.random(-1000,1000) -- creates a random y axis position for the eggs

	local EggClone = Eggs[math.random(1, #Eggs)]:Clone() --- Finds a new random egg from the egg folder
	EggClone.Position = Part.Position + Vector3.new(X,0,Z)
	EggClone.Parent = workspace -- puts the egg in workspace 
	Debris:AddItem(EggClone,50) -- How long the eggs will last before it despawns
	print("Egg Cloned")
	print(EggClone.Name)

    EggClone.Touched:Connect(function(hit) --- When the egg is touched by an object
		if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("Humanoid") then
			print("Got Egg "..EggClone.Name.."")
			if EggClone.Name ==  ("Your egg's name")  then
				--- Effect
			end
			local Hat = EggHats:FindFirstChild(EggClone.Name)
			for _,v in pairs(hit.Parent:GetChildren()) do
				if v:IsA("Accessory") then
					v:Destroy() -- Removes the Accessories from the player so the egg is visible
				end
			end
			Hat:Clone().Parent = hit.Parent --- Adds egg to the avatar
			EggClone:Destroy() -- Destroys the egg
		end
	end)
end

I hope you enjoyed making your new Egg Hunt Game! Just like egg hunt 2008.
By the way, this is my first tutorial so if there is any mistakes let me know! Any feedback is appreciated!

:egg:Happy Easter!:egg:

18 Likes

That sounds really cool! I won’t use it but I can say this is such a great idea for easter times!

1 Like

Very cool that you also included hats thanks

1 Like