Hi! I’m trying to figure out how I could make an “info” sort of command for staff members, which would send a game notification only for the client when they’ve run the command. I understand how to make the command itself, but I’m not sure how I’d get the command to send them this info notification when they’ve said the command. How could I go about doing this?
For a bit more reference, the command will be set as !info username - the notification it sends will show certain information about the player they named in the command.
Use the player.Chatted event on the local player like so, this will make it so if the user’s chat begins with any capitalization of “!info”, it’ll do something, in this case prints that the local player said “!info”:
local players = game:GetService('Players')
local localPlayer = players.LocalPlayer
localPlayer.Chatted:Connect(function(message)
if message:lower():sub(1,5) == '!info' then
-- the player's message started with "!info"
print(localPlayer,'said !info')
end
end)
I know how to make the chat command, I’m just confused with making the outcome (which would be a game notification sent to the client’s screen - pretty much something like this just working with the command)
--Server
--Variables
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:FindFirstChild("MyRemote")
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message:lower():sub(1,5) == '!info' then
Remote:FireAllClients(Player.Name.." has just said '!info'!")
end
end)
end)
–Client
--Variables
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("MyRemote")
Remote.OnClientEvent:Connect(function(Message)
game.StarterGui:SetCore("SendNotification",{
Title = "New Message",
Text = Message
})
end)