Forcing a plr to chat

Hey there. So i was trying to script a textbutton where, if a player presses it. It force chats the text for them. And, im not talking about the Bubble Chat. I know how to do that BUT. i want to make it so thay like yk when we chat normally it shows and chat and a bubble chat and visible to everyone. I want that when they press a button, they will be chatted.

TextChannel:SendAsync could be of use. Get the RBXGeneral Textchannel from TextChatService and use SendAsync on it.

1 Like

Can you give me a implementation? Im new to scripting.

1 Like

Sorry to be a party-breaker but, If you’re doing this for EVERYONE, then this would possible be against ToS…
Here’s why:

Let’s say I’m a parent who explicitly turned off chat for my child (A) within the Roblox privacy settings. (For many reasons of course).
If a game allows a player to ‘force-chat’, Child (A) may be able to communicate with others even though I (the parent in this scenario) explicitly denied this.
(The example parent here does not want ANY direction of communication via chat, Not Inbound, Not Outbound).

If you’re making something somewhat of a Quickchat system, you’ll need to make sure the player is indeed ALLOWED to chat (Publicly) in the first place. (I’ll search for a snippet for this).

Hopefully this helps ya. :]

Edit: You can find the CanUserChatAsync here to help: https://create.roblox.com/docs/reference/engine/classes/TextChatService#CanUserChatAsync

Sure.

local TextChatService = game:GetService "TextChatService"
local TextChannel = TextChatService:WaitForChild "TextChannels" : WaitForChild "RBXGeneral" :: TextChannel
--parenthesis are optional in calls with one literal argument
TextChannel:SendAsync "Hello"

This sends hello in chat.

Edit: like @AmazingBarnabe said, you might want to check for chat enabled. Use TextChatService:CanUserChatAsync to determine if the user can chat.

Im not using bad words tho, roblox should automatically tag it for everyone if it contains.

I understand that, but from the example parent’s views, you are saying ‘No, let this person chat’.

It’s like the parent saying ‘No I don’t want Full Self Driving on my car’ but they (you) force it onto the car.

You need to take account the parent’s POV aswell as the user’s POV.

1 Like

Doesn’t matter. Sometimes a parent doesn’t want their child to interact with strangers online, for obvious reasons

local tcs = game:GetService(“TextChatService”)
local textchannel = tcs:WaitForChild(“TextChannels”)

game.Players.PlayerAdded:Connect(function(player)
task.wait(2)
textchannel:SendAsync(player, “Hello”)
end)

Is this script good?

You forgot to include the RBXGeneral call. You’re waiting for the folder named textchannels instead of rbxgeneral.

Sendasync only works on the client btw.

As @scavengingbot here says, if you forget to define WHERE to chat, the script will put up an error

I put that script on the StarterPlayerScripts as its for client. I did define the RBX General in the script, it still didnt work.

local tcs = game:GetService(“TextChatService”)
local textchannel = tcs:WaitForChild(“TextChannels”):WaitForChild(“RBXGeneral”)

game.Players.PlayerAdded:Connect(function(player)
task.wait(2)
textchannel:SendAsync(player, “Hi”)
end)

You don’t pass the player as an argument. You pass only the message. It uses the LocalPlayer as the target player.

Edit: for security reasons, clients can’t force other clients to talk

I removed the player as an arguement, it still did not work. I guess it didnt work because textchannel:SendAsync wasnt an function. When i tried to write that, it didnt give me like a popup.

No, that’s because intellisense doesn’t know that TextChannel is a textchannel, because waitforchild returns Instance, not TextChannel. So the intellisense thinks it is of type instance, therefore it doesn’t give you the popup. However, it is a valid function that accepts a message string.

Try removing the playeradded event handler. You see, playeradded fires before your local script connects the handler to it, which is why nothing happens.

Edit: intellisense doesn’t know everything, so to check if something is a real fn, use the docs. To aid intellisense in identifying object types, use Type Annotations or typecasting.

I did a bit of googling on the side and found this too, you can have a quick glance and see if it helps

Oh! It worked, thank you. I couldnt search the devforum, because it was confusing much. Thanks.

1 Like

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