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
--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)
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
--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
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)