Why cant players see other players chat messages when this script is enabled?

For some reason when this script is enabled, players cant see other players chat, any help?

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

local function setprefixtext(value, message)
	return "<font color='#"..(value:WaitForChild("Color").Value):ToHex().."'>["..value.Name.."]</font> " .. message.PrefixText
end

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 839718134) then
			props.PrefixText = setprefixtext(script:WaitForChild("V.I.D"), message)
		end
			
		if player.UserId == 869133154 then
			props.PrefixText = setprefixtext(script:WaitForChild("OWNER"), message)
		end
		
		if player.UserId == 647598508 then
			props.PrefixText = setprefixtext(script:WaitForChild("DEVELOPER"), message)
		end

	return props	
	end
end

The logic of your code, and how you’re altering the incoming message, is correct.
The issue probably lies in the way your instances are setup, going wrong at one of your WaitForChild.

  • Can you send a screenshot of the script and all it’s children in your Explorer?
  • When a message is not being sent, are you not getting any errors in your Output window (give it 10 seconds).

image
also yes i am not getting any errors, sorry forgot to answer to that (edited)

I tested your code and I do get an error.

Error occurred while calling TextChatService.OnIncomingMessage: MarketPlace:UserOwnsGamePassAsync() can only query local player

This means you cannot use Marketplace:UserOwnsGamePassAsync() to check if other players own a game pass. To do so anyway you can use a RemoteFunction to have the server perform the check for the client.

The way I tested this

was by starting a Local Server with two players:


Then when I sent a message with player1 (left), an error occurs in the Output window of player2 (right)

ohhh okay, thank you so much!

charcharcharcharcharchar

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.