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.
Can you give me a implementation? Im new to scripting.
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.
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.
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.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.