I'm trying to make a pet hatching system using ROBLOX's map chooser article and change it up a bit, but I have no idea why it doesn't work. I tried debugging but that wouldn't help either. Script Analysis isn't showing any errors either.

Here's the LocalScript, which is located in StarterPlayerScripts.

local event = game.ReplicatedStorage.Events:WaitForChild("EggHatching")
local player = game.Players.LocalPlayer
event.OnClientEvent:Connect(function()
	local replicatedStorage = game:GetService("ReplicatedStorage")
local typeofpet = replicatedStorage:WaitForChild("TypeOfPet")
local plrgui = player:WaitForChild("PlayerGui")
print 'good0' 
local function pickMap()
	local petList = typeofpet:GetChildren()
	print 'goodx' -- Declares a table of the maps inside of the Maps folder.
	local selectedIndex = math.random(1,#typeofpet) -- Choose a random number between 1, and the number of maps available.
	local pet = petList[selectedIndex]:Clone() -- Create a clone of the map we selected.
	print 'good1' 
	pet.Parent = plrgui -- Parent it to the workspace.
	print 'good2'
	pet.Name = "Pet" -- Rename the map so that we can use the unloadMap() function later to remove it.
	return petList[selectedIndex].Name -- Return the name of the map we selected, in case we want to display it.
	end 
end) 

And the ServerScript, which is in a Part with a ClickDetector.

script.Parent.ClickDetector.MouseClick:Connect(function(a)
	script.Parent.ClickDetector.MaxActivationDistance = 0
	local event = game.ReplicatedStorage.Events:WaitForChild("EggHatching")
	event:FireClient(a)
	script.Parent.ClickDetector.MaxActivationDistance = 32
end) 

I hope there's a solution for this.