if player.UserId == 411491496 then
player.Chatted:Connect(function(chat)
local success, errorMessage = pcall(function()
local str = string.split(chat," ")
print(str)
if str[1] == "!givepet" then
local playerToGive = game.Players:FindFirstChild(str[2])
if playerToGive ~= nil then
local pet = str[3]
if pet ~= nil and RS.Pets:FindFirstChild(pet,true) then
local val = Instance.new("StringValue")
val.Name = pet
AttachUUID(val)
val:SetAttribute("Level",1)
val:SetAttribute("Equipped",false)
val.Parent = playerToGive.OtherStats.Pets
end
end
elseif string.lower(str[1]) == "!givegamepass" then
local playerToGive = game.Players:FindFirstChild(str[2])
if playerToGive ~= nil then
local gamepass = str[3]
if gamepassIDs[gamepass] then
if player.OtherStats.Gamepasses:FindFirstChild(gamepass) then
else
local val = Instance.new("StringValue")
val.Name = gamepass
val.Parent = playerToGive:FindFirstChild("OtherStats"):FindFirstChild("Gamepasses")
if val.Name == "+2Pets" then player.OtherStats:FindFirstChild("MaxPetsEquipped").Value += 2 end
if val.Name == "+5Pets" then player.OtherStats:FindFirstChild("MaxPetsEquipped").Value += 5 end
if val.Name == "+150PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 150 end
if val.Name == "+350PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 350 end
if val.Name == "+750PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 750 end
if val.Name == "+1200PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 1200 end
end
end
end
end
end)
if errormessage then print(errormessage) end
end)
end
How can i make the chat delete? server sided^
1 Like
Chat messages are stored in GUIs and cannot be deleted by the server
if i were to do fireallclients on a remote event, what would i do on the local side of the fireallclients? just chat:destroy() or what
Well deleting chat messages is pretty hard to do since all the messages are just named ‘Frame’, but you could try doing
for _,v in pairs(game.Players.LocalPlayer.PlayerGui.Chat.Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller:GetChildren()) do
if v:IsA("Frame") and v:FindFirstChild("TextLabel") and string.match(v.TextLabel.TextButton.Text,<DisplayName>) then
v:Destroy()
end
end
ReplicatedStorage.Remotes.Admin.OnClientEvent:Connect(function(message)
wait()
print(2)
for _, v in pairs(player.PlayerGui.Chat.Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller:GetChildren()) do
print(3)
if v:IsA("Frame") and v:FindFirstChild("TextLabel") then
print(4)
if v.TextLabel:FindFirstChild("TextButton") then
print(5)
if string.match(v.TextLabel.Text,message) then
print(6)
v:Destroy()
end
end
end
end
end)
This works, but without the wait it doesnt work. I dont know why
Does this remote fire to all clients? Because if not, then I suppose that only the admin won’t be able to see these chats.
it does fire to all clients(30)
Oh sorry, I didn’t read your previous replies and I was only asking based on the information given by your post.
Is the remote fired as soon as the message is sent?
You can’t without forking the Chat.
if player.UserId == 411491496 then
player.Chatted:Connect(function(chat)
local success, errorMessage = pcall(function()
local str = string.split(chat," ")
if str[1] == "!givepet" then
RS.Remotes.Admin:FireAllClients(str[1])
local playerToGive = game.Players:FindFirstChild(str[2])
if playerToGive ~= nil then
local pet = str[3]
if pet ~= nil and RS.Pets:FindFirstChild(pet,true) then
local val = Instance.new("StringValue")
val.Name = pet
AttachUUID(val)
val:SetAttribute("Level",1)
val:SetAttribute("Equipped",false)
val.Parent = playerToGive.OtherStats.Pets
end
end
elseif string.lower(str[1]) == "!givegamepass" then
RS.Remotes.Admin:FireAllClients(str[1])
local playerToGive = game.Players:FindFirstChild(str[2])
if playerToGive ~= nil then
local gamepass = str[3]
if gamepassIDs[gamepass] then
if player.OtherStats.Gamepasses:FindFirstChild(gamepass) then
else
local val = Instance.new("StringValue")
val.Name = gamepass
val.Parent = playerToGive:FindFirstChild("OtherStats"):FindFirstChild("Gamepasses")
if val.Name == "+2Pets" then player.OtherStats:FindFirstChild("MaxPetsEquipped").Value += 2 end
if val.Name == "+5Pets" then player.OtherStats:FindFirstChild("MaxPetsEquipped").Value += 5 end
if val.Name == "+150PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 150 end
if val.Name == "+350PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 350 end
if val.Name == "+750PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 750 end
if val.Name == "+1200PetStorage" then player.OtherStats:FindFirstChild("MaxPetStorage").Value += 1200 end
end
end
end
end
end)
if errormessage then print(errormessage) end
end)
end
this is the updated code
wdym idk what forking the chat is
Basically going into the game and copying the entire contents of the chat folder somewhere.
why would i need to do that? it is working with the wait, im just wondering why it isnt working without the wait
You should probably just keep the wait there, it doesn’t really mess with the code or anything
Maybe it’s because it needs time to load? It may happen too quickly for the game to process or something like that.
You can use the same principles as this:
local chatGUI = plr.PlayerGui.Chat
local children = chatGUI.Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller:GetChildren()
for _, v in pairs(children) do
if v:IsA("Frame") then
v:Destroy()
end
end
But as you said you want this in the server, just make a :FireAllClients()
and have a script to handle the code above when it receives such event.
ok, I found a bug. On other player’s chats they still see the message, but on mine i dont see it. Why is that?

ReplicatedStorage.Remotes.Admin.OnClientEvent:Connect(function(message)
wait()
for _, v in pairs(player.PlayerGui.Chat.Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller:GetChildren()) do
if v:IsA("Frame") and v:FindFirstChild("TextLabel") then
if v.TextLabel:FindFirstChild("TextButton") then
if string.match(v.TextLabel.Text,message) then
v:Destroy()
end
end
end
end
end)
I did.(3030030303030303030303030)