Help GUI that sends a message through the player

I’m trying to make a GUI that when clicked sends a message in chat for the player.

For example if I put a button with an emoji and one clicks it I want in the chat to be: [ironboy1965]::grinning:
But I want it to be instant at the click of the button without having to hit enter.

I trying using system messages but I cant get to write the name of the player like in a normal chat. I’m not sure what I’m supposed to use for this and there is little to no documentation from Roblox.

1 Like

What have you tried so far? Some code? What the button looks like? Please provide a some more detail

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

Do you understand what the script does? Please read this documentation:
https://create.roblox.com/docs/reference/engine/classes/Chat

I guess you got your script off youtube, which isn’t a problem, but first you should understand how it works, and only then use it.
Your script will look 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")
    game.StarterGui:SetCore("ChatMakeSystemMessage",{
        Text = "["..Player.Name.."]: ABC"; --change ABC to the text you want the player to send
    })
end)

Also, this is a LocalScript, so only you will see the message. Change it to a ServerScript if you want every player to see it

1 Like

I tried to make it server but it gives to me this error and the message didn’t appear on the chat but only on the bubble:

StarterGui:SetCore must be called from a local script. - Studio

 local Button = script.Parent
local Event = Button.RemoteEvent

Button.MouseButton1Click:Connect(function()
    Event:FireServer("Test")
end)
 --Variables
local Chat = game:GetService("Chat")
local Event = script.Parent.RemoteEvent

Event.OnServerEvent:Connect(function(x, argument)
    local Char = x.Character
    if argument == "Test" then
        Chat:Chat(Char:WaitForChild("Head"),"👮")
        game.StarterGui:SetCore("ChatMakeSystemMessage",{
            Text = "["..x.Name.."]: ABC"; --change ABC to the text you want the player to send
        })
    end
end)

Yes, the SetCore has to be in a LocalScript, but the Chat:Chat has to be in a ServerScript. You can use a remote event to do this, please watch a tutorial about them, and here’s the official documentation:
https://create.roblox.com/docs/scripting/events/bindable-events-and-functions

yes I know how Remote functions work, but I don’t know what I have to do with the Chat:Chat, cause I never worked with the Chat Service

Its going to be the same. So you will have the event handler something like this:

local Chat = game:GetService("Chat")

... function(player)

local char = player.Character -- you can also just pass the character as an argument, it might be easier
Chat:Chat(char:WaitForChild("Head"),"👮")

end)

I never worked with the chat service either, but it should work

1 Like