Jaxxon Jargon's Egg Hunt - Open Source & Uncopylocked

I created a simple egg hunt game and am sharing it with everyone by uncopylocking the game:

This game would be good for someone new to scripting. For example, the bulk of the game is expressed in this simple EggManager LocalScript:

local SoundService = game:GetService("SoundService")

local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://1869741275" -- Applause.
sound.Volume = 5

for _, model in ipairs(workspace.HiddenEggs:GetChildren()) do
	local egg = model.Egg
	local gem = model.Gem
	local prompt = Instance.new("ProximityPrompt")
	egg.BrickColor = BrickColor.random()
	prompt.ActionText = "Collect"
	prompt.MaxActivationDistance = 5 -- Default is 10.
	prompt.ObjectText = tostring(egg.BrickColor) .. " egg"
	prompt.Parent = egg
	prompt.Triggered:Connect(function(player)
		egg.Transparency = 1
		gem.Material = Enum.Material.Plastic
		prompt.Enabled = false
		model.Parent = workspace.FoundEggs
		sound.Parent = egg
		sound:Play()
		sound.Parent = SoundService
	end)
end

Enjoy and let me know what you think.

6 Likes

I’ve been experimenting with Humanoid.JumpPower and it is so much fun to be able to jump high. And it makes it easier to get on the roof of a building. So now when you find all the hidden eggs your JumpPower increases from 50 to 60. But if you’re like me you hate to wait so I added some backdoors to this powerup. The J key changes the JumpPower to 60, K changes it to 80, and L changes it to 100.

As usual, let me know what you think of the game and these changes. And if you want to know how I implemented these features you have full access to the code and map. Just copy it from Roblox and edit it in Studio. Enjoy!

1 Like

Egg management has gotten slightly more complex. Now I have the eggs play the sound of chirping birds when the player gets close to an egg (similar to the “warmer” and “colder” hints in the traditional IRL egg hunt game). This is in addition to the applause sound that gets played when an egg is collected.:

local SoundService = game:GetService("SoundService")

local applauseSound = Instance.new("Sound")
applauseSound.SoundId = "rbxassetid://1869741275" -- Applause.
applauseSound.Volume = 5

for _, model in ipairs(workspace.HiddenEggs:GetChildren()) do
	local egg = model.Egg
	local gem = model.Gem
	local natureSound = Instance.new("Sound")
	local prompt = Instance.new("ProximityPrompt")
	egg.Anchored = true
	egg.BrickColor = BrickColor.random()
	natureSound.Looped = true
	natureSound.RollOffMaxDistance = 20
	natureSound.SoundId = "rbxassetid://169736440" -- ForestAmbienceVar2
	natureSound.Volume = 3
	natureSound.Parent = egg
	natureSound:Play()
	prompt.ActionText = "Collect"
	prompt.MaxActivationDistance = 5 -- Default is 10.
	prompt.ObjectText = tostring(egg.BrickColor) .. " egg"
	prompt.Parent = egg
	prompt.Triggered:Connect(function(player)
		egg.Transparency = 1
		gem.Material = Enum.Material.Plastic
		model.Parent = workspace.FoundEggs
		natureSound:Stop()
		prompt.Enabled = false
		applauseSound.Parent = egg
		applauseSound:Play()
		applauseSound.Parent = SoundService
	end)
end
2 Likes

I’ve made a number of changes to this game so you might want to look at this latest version. In particular, the game now increases your Jump Power and Walk Speed every time you collect an egg. That means you can end up jumping incredibly high and walking quite fast. Which is a lot of fun. So try it out and let me know what you think. (Keep in mind that I’m targeting younger players with this game.)

As for the code, I’m still focused on minimal, readable code. For example, here is how I handle the Jump Power increases:

local Players = game:GetService("Players")

local jumpPower = require(script.Parent:WaitForChild("JumpPower"))

local player = Players.LocalPlayer

local INITIAL_JUMP_POWER = 0
local MAX_JUMP_POWER = 1000

local function setupJumpPower()
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	humanoid.JumpPower = INITIAL_JUMP_POWER
end

setupJumpPower()

workspace.FoundEggs.ChildAdded:Connect(function()
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	if humanoid.JumpPower < MAX_JUMP_POWER then
		humanoid.JumpPower += 10
	end
end)

player.CharacterAdded:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")
	humanoid.JumpPower = jumpPower.currentJumpPower
end)

player.CharacterRemoving:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")
	jumpPower.currentJumpPower = humanoid.JumpPower
end)
1 Like

And here is how I keep a Text Label updated with the current Jump Power:

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")

local textLabel = script.Parent

local function update()
	textLabel.Text = "Jump Power: " .. tostring(humanoid.JumpPower)
end

update()

humanoid:GetPropertyChangedSignal("JumpPower"):Connect(function()
	update()
end)
1 Like

I thought this game was polished enough to do a short intro video, so here it is:

Things have gotten a bit more interesting with the addition of a fully functioning minimap display that shows you where you are in the map, rotates with the camera, shows the location of all the gems, etc. I used the terrific combination of RoRender and Plum’s minimap to achieve this and I have to say that I am really satisfied with the result. Let me know what you think.

Just an update to let you all know that I’ve been playing this game on my phone and so I spent time moving around the various GUI elements so they look good on the phone. Enjoy.