This is destroying roblox servers

You won’t believe this but, in my game, I made a script and when someone sends a message in chat more than 2-4 times, the game won’t crash, the Roblox client itself is missing.
I had to remove this script, to continue the playing of my game.

local tcs = game:GetService("TextChatService")

tcs.OnIncomingMessage = function(message)
	if message.Status ~= Enum.TextChatMessageStatus.Success then
		return
	end
	if message.TextSource == nil then
		return
	end
	if message.TextSource.UserId == nil then
		return
	end
	local plr = game.Players:GetPlayerByUserId(message.TextSource.UserId)
	if plr ~= nil then
		if plr:GetAttribute("PremiumUser") == true then
			local newproperties = Instance.new("TextChatMessageProperties")
			newproperties.PrefixText = "👑 "..message.PrefixText
			return newproperties
		elseif plr.MembershipType == Enum.MembershipType.Premium then
			local newproperties = Instance.new("TextChatMessageProperties")
			newproperties.PrefixText = '<font color="rgb(255,255,255)">'.."\u{E001}</font> "..message.PrefixText
			return newproperties
		elseif plr.AccountAge%365 == 0 then
			local newproperties = Instance.new("TextChatMessageProperties")
			newproperties.PrefixText = "🎂 "..message.PrefixText
			return newproperties
		elseif plr:IsFriendsWith(game.Players.LocalPlayer.UserId) then
			local newproperties = Instance.new("TextChatMessageProperties")
			newproperties.PrefixText = "🙂 "..message.PrefixText
			return newproperties
		end
	end
end

Why does this happen? It works fine in studio, but in-game it will show its power :sad:

2 Likes

Man it must be tough reading the documentation, don’t use GetPlayerByUserId here.

1 Like

1 Like

pls bro i need that first image of the tiger right now bro pleas

1 Like

See, why does it crash the game if i use it? thats not how it works right?

2 Likes

My bad, I thought GetPlayerByUserId yields, which it doesn’t, instead remove IsFriendsWith

1 Like