ShouldDeliverCallback isn't being called

I am trying to make a proximity chat, in which you get the message if the player sending it is within a certain distance from you. My friend found Roblox’s official example in the documentation, but when I paste it in, it doesn’t seem to work. When I try to local server test with two players, player 2 still receives a message from player 1 despite being 500 studs away, while I set it to not let anyone above 50.

I tried debugging it with breakpoints and print, but the ShouldDeliverCallback never gets called. I even tried it with my friend through the player (not studio), and sure enough, I still get his message despite being 500 studs away, and nothing gets printed in the server log.

The script itself is inside ServerScriptService with Server RunContext.

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

local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral

local function getPositionFromUserId(userId: number)
	local targetPlayer = Players:GetPlayerByUserId(userId)

	if targetPlayer then
		local targetCharacter = targetPlayer.Character
		if targetCharacter then
			return targetCharacter:GetPivot().Position
		end
	end

	return Vector3.zero
end

generalChannel.ShouldDeliverCallback = function(textChatMessage: TextChatMessage, targetTextSource: TextSource)
	local sourcePos = getPositionFromUserId(textChatMessage.TextSource.UserId)
	local targetPos = getPositionFromUserId(targetTextSource.UserId)
	
	print("proximity debug " .. (targetPos - sourcePos).Magnitude)

	return (targetPos - sourcePos).Magnitude < 50
end

the docs that I used:

That’s weird, the code that’s in the documentation is working well for me in a file I just created to test it (perhaps, attempt to create a new file, paste the script in ServerScriptService, and see if it works just to verify your Studio client is not faulty).

Some things I would look out for:

  • Is it throwing any errors/warnings in your Output?
  • Are you using the new ‘Channels Tabs’? If so, I think you need to specify which Channel you want to check for user proximity (that code is set to RBXGeneral, for instance).

Do note that I’m pretty sure that the scripts in the In-Experience Text Chat | Documentation - Roblox Creator Hub page will only work for TextChatService, and any attempt to run them in LegacyChatService won’t function properly (unless explicitly stated, obviously).

Let me know if this helps.

okay, it did work in a fresh baseplate. The weird thing is that the place where it didn’t work was also a fresh baseplate I made a few days ago. Perhaps Adonis is interfering with it?

yup it did, there is a boolean value in Adonis settings OverrideChatCallbacks that is set to true by default so putting it on false fixed it. I hope it doesn’t limit Adonis’ capabilities so much

1 Like

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