I’m sort of new to scripting and I wanted to make the chat change to a purple-ish color when they type “(( /me {what player types} ))”.
and how would the chat know which body part the player was damaged at and ‘types’ it in?
Ex: “[!] you have been damaged in your lower torso and need to seek medical attention”
Thank you in advance and sorry if asking too much I am slowly understanding how to script.
Here is a solution to what you want above the picture.
–Server script (ServerScriptService)
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local function ChangeChatColor(player)
local speaker = ChatService:GetSpeaker(player.Name)
speaker:SetExtraData("ChatColor", Color3.new(0.764706, 0.431373, 1)) --change color your custom
task.wait()
speaker:SetExtraData("ChatColor", Color3.new(1, 1, 1)) --change color back
end
RemoteEvent.OnServerEvent:Connect(ChangeChatColor)
–LocalScript (StarterGui)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
player.Chatted:Connect(function(msg) --registers when a player writes something
local values = msg:split(" ") --split msg into 2 parts
if values[1] == "/me" then --if 1 part msg = "/me" then
RemoteEvent:FireServer() --send server player name (I use a server for everyone to see(change color))
end
end)
It mean, the message is divided into pieces according to where the gap is located.
EXAMPLE:
message: “hi my name is autumn” →
message[1] = hi
message[2] = my
message[3] = name
message[4] = is
message[5] = autumn
then I use message[1] to know if it equals = “/me”
local Color = Color3.new(0.764706, 0.431373, 1)
speaker:SetExtraData('NameColor', Color) --change name
speaker:SetExtraData("ChatColor", Color) --change text
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local function ChangeChatColor(player)
local speaker = ChatService:GetSpeaker(player.Name)
speaker:SetExtraData("NameColor", 0.764706, 0.431373, 1)
speaker:SetExtraData("ChatColor", Color3.new(0.764706, 0.431373, 1)) --change color your custom
task.wait()
speaker:SetExtraData("ChatColor", Color3.new(1, 1, 1)) --change color back
end
RemoteEvent.OnServerEvent:Connect(ChangeChatColor)
Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.RemoteEvents.RemoteEvent:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
player.Chatted:Connect(function(msg) --registers when a player writes something
local values = msg:split(" ") --split msg into 2 parts
if values[1] == "/me" then --if 1 part msg = "/me" then
RemoteEvent:FireServer() --send server player name (I use a server for everyone to see(change color))
player.Chatted:Connect(function(msg) --registers when a player writes something
local values = msg:split(" ") --split msg into 2 parts
if values[1] == "/do" then --if 1 part msg = "/me" then
RemoteEvent:FireServer() --send server player name (I use a server for everyone to see(change color))
end
end)
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
player.Chatted:Connect(function(msg)
local values = msg:split(" ")
RemoteEvent:FireServer(values[1])
end)
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local Color
local function ChangeChatColor(player,text)
local speaker = ChatService:GetSpeaker(player.Name)
if text == "/me" then
local Color = Color3.new(0.764706, 0.431373, 1)
Change(speaker,Color)
end
if text == "/do" then
local Color = Color3.new(1, 0.423529, 0.431373)
Change(speaker,Color)
end
end
RemoteEvent.OnServerEvent:Connect(ChangeChatColor)
function Change(speaker,Color)
speaker:SetExtraData('NameColor', Color)
speaker:SetExtraData("ChatColor", Color)
task.wait()
Color = Color3.new(1, 1, 1)
speaker:SetExtraData('NameColor', Color)
speaker:SetExtraData("ChatColor", Color)
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
player.Chatted:Connect(function(msg)
local values = msg:split(" ")
RemoteEvent:FireServer(values[1])
end)
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local Color
local function ChangeChatColor(player,text)
local speaker = ChatService:GetSpeaker(player.Name)
if text == "/me" then
local Color = Color3.new(0.764706, 0.431373, 1)
Change(speaker,Color)
end
if text == "/do" then
local Color = Color3.new(1, 0.423529, 0.431373)
Change(speaker,Color)
end
end
RemoteEvent.OnServerEvent:Connect(ChangeChatColor)
function Change(speaker,Color)
speaker:SetExtraData('NameColor', Color)
speaker:SetExtraData("ChatColor", Color)
task.wait()
Color = Color3.new(1, 1, 1)
speaker:SetExtraData('NameColor', Color)
speaker:SetExtraData("ChatColor", Color)
end
And if you want to make this red message, you can use this local script (StarterGui):
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[!] Write Your Text";
Font = Enum.Font.SciFi;
Color = Color3.new(0, 0.4, 1);
FontSize = Enum.FontSize.Size96;
})