How to make a player say a chat on the client

hello im trying to make a script that when the player clicks button it makes them say “Thank you”

i know there already solutions for remote events etc that make the player chat however its really hard to explain but i want to only do it on the client

its for some security reasons and my own personal want. i understand i can make a remote event only say one thing but i very much pefer to only do it on the client.

please do not tell me to do it on the server as there is nothing you can tell me that will change my mind. i dont care if it doesnt look extremely realistic just as long as it pops up as bubblechat and also in the chat box

1 Like

Do you mean something like this?

--Variables
local Chat = game:GetService("Chat")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

local Button = script.Parent.TextButton


--Functions
Button.MouseButton1Click:Connect(function()
	Chat:Chat(Char:WaitForChild("Head"),"Thank you")
end)
3 Likes

does it say the chat in the chat box as well
edit: it doesnt look like it says it in the chat box by the script you sent. it also looks like it only runs for that

nevermind you do run a function

i tested it in roblox studio and it doesnt pop up for other players and also it doesnt put a message in the chat.

is there ANY possible other solutions on the client that work?

If you want it to send it on chat aswell,
you could use

game.StarterGui:SetCore("ChatMakeSystemMessage",{
      Text = "Thank you";
})

If you want this to be shown to everyone in the server,
Use a remote.

1 Like
--Variables
local Chat = game:GetService("Chat")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

local Button = script.Parent.TextButton


--Functions
Button.MouseButton1Click:Connect(function()
	Chat:Chat(Char:WaitForChild("Head"),"Thank you")
	game.StarterGui:SetCore("ChatMakeSystemMessage",{
		Text = "{System}Thank you "..Player.Name.." for clicking on the button1";
	})
end)

If you wanted to make it on server side,
you could fire a remote inside the MouseButton1Click event,
and then on the server, fire it back to all clients and call game.StarterGui:SetCore("ChatMakeSystemMessage",{ Text = "{System}Thank you "..Player.Name.." for clicking on the button1"; }) inside that event

1 Like

its whatever if i have to do it on the server but i worry people will abuse it and make everyone in the server spam Thank You

wait it says StarterGui:SetCore must be called from a local script. also it doesnt say the message in chat it only says bubble chat

That is true.
If you still want everyone to see it,
simply fire a remote from the server(FireAllClients) , and then call that on the client.

What do you mean?
For me it works perfect

1 Like

i found a different resource which is similar to yours but it shows the username name in chat as well. thanks for the help

It is not necessary to create a “Remote Event” because roblox already creates it when you enter the game

Look for Remote In ReplicatedStorage a RemoteEvent Called From: SayMessageRequest

After, if you want to do this for everyone on the server by clicking on a button, you can use the script below:

local Button = script.Parent
local Message = "Thank you"

Button.MouseButton1Click:Connect(function()
	game:GetService("ReplicatedStorage"):WaitForChild("DefaultChatSystemChatEvents"):FindFirstChild("SayMessageRequest"):FireServer(Message, "All") -- "All"
end)
2 Likes