Chat populating with blank messages

I have a game that adds a few lines to the base “DefaultChatMessage” script. Despite very little changes - and a 99% success rate - there is this bizarre bug where the chat window becomes increasingly populated with blank messages.


(the scrollbar is unusable despite the chat being filled beyond the few messages shown)

Here are the changes I made to the script:

function CreateMessageLabel(messageData, channelName)

	local fromSpeaker = messageData.FromSpeaker
	local speakerName

	if ChatSettings.PlayerDisplayNamesEnabled and messageData.SpeakerDisplayName then
		speakerName = messageData.SpeakerDisplayName
	else
		speakerName = fromSpeaker
	end
	
	local speakerUserId = messageData.SpeakerUserId
	if IsPlayerVerified(speakerUserId) then
		speakerName = AppendVerifiedBadge(speakerName)
	end

	-- my changes
	local speaker = PlayersService:FindFirstChild(fromSpeaker)
	if speaker and speaker ~= localClient then
		if not speaker:GetAttribute("InGame") and localClient:GetAttribute("InGame") then
			if localClient:GetAttribute("Role") ~= "Medium" then
				return
			else
				messageData.ExtraData.NameColor = Color3.fromRGB(77, 77, 77)
				speakerName = "💀 Dead Player"
			end
		end
	end

...

Any ideas how I could fix this problem?