I made a phone system that allows you to communicate / send messages to other players. The problem is you can swear and there’s no filtering at all. How do I fix this?
I use remote events to send the text that players type in the phone to other players. I didn’t even think this was possible…
local p = script.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
if game.Players:FindFirstChild(p.PlayerTarget.Text) then
game.ReplicatedStorage.Remotes.GetMessage:FireServer(p.PlayerTarget.Text,p.Message.Text)
else
p.PlayerTarget.Text = "Invalid username!"
end
end)
this is inside the send button ^
local event = game.ReplicatedStorage.Remotes:WaitForChild("GetMessage")
event.OnServerEvent:Connect(function(player,target,message)
if game.Players:FindFirstChild(target) ~= nil then
if game.Players:FindFirstChild(target):WaitForChild("MutedPlayers"):FindFirstChild(player.Name.."_folder") == nil then
game.ReplicatedStorage.Remotes:WaitForChild("SendMessage"):FireClient(game.Players:FindFirstChild(target),player,message)
end
end
end)
^ this is inside the serverscriptservice.
local plr = game.Players.LocalPlayer
local playerGui = plr.PlayerGui
local inbox = playerGui:WaitForChild("MessageGui"):WaitForChild("Frame")
local store = inbox:WaitForChild("Holder"):WaitForChild("ScrollHolder")
local chat = script:WaitForChild("PlayerChat")
game.ReplicatedStorage.Remotes:WaitForChild("SendMessage").OnClientEvent:Connect(function(player,text)
inbox.Visible = true
for i, v in pairs(store:GetChildren()) do
v.Position = v.Position + UDim2.new(0,0,0.13,0)
end
local c = chat:Clone()
c.Parent = store
c.Player.Text = player.Name
c.TextInfo.Text = text
end)
this is inside the startercharacterscripts ^ it gets the message and displays it on the phone.