I am
trying to filter texts to make posts.
SERVER
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local HttpsService = game:GetService("HttpService")
local DatastoreServive = game:GetService("DataStoreService")
local TextService = game:GetService("TextService")
--// Datasores
local Data_TotalAmount = DatastoreServive:GetDataStore("TotalAmountOfPosts")
--// Objects
local Events = ReplicatedStorage:WaitForChild("Events")
local TotalVal = Instance.new("IntValue")
--// Events
local SendPost = Events:WaitForChild("SendPost")
local ChangeData = Events:WaitForChild("ChangeData")
local ClientToServer = Events:WaitForChild("SendFilterSignalToServer")
local ServerToClient = Events:WaitForChild("SendFilterSignalToClient")
--// Code
TotalVal.Value = 0
ClientToServer.OnServerEvent:Connect(function(Player, T, M)
local filtertedText = ""
local filteredMessage = ""
local success, errorMessage = pcall(function()
filtertedText = TextService:FilterStringAsync(T, Player.UserId)
print(tostring(filtertedText))
end)
if not success then
print(errorMessage)
end
local success2, errorMessage2 = pcall(function()
filteredMessage = TextService:FilterStringAsync(M, Player.UserId)
ServerToClient:FireClient(Player, filteredMessage, filtertedText)
print(filteredMessage)
end)
if not success2 then
print(errorMessage)
return
end
if success and success2 then
ServerToClient:FireClient(Player)
end
end)
MessagingService:SubscribeAsync("SendPost", function(messages)
messages = messages.Data
print(messages[1])
print(messages[2])
print(messages[3])
print(messages[4])
TotalVal.Value = TotalVal.Value +1
for _, player in pairs(Players:GetPlayers()) do
if player.PlayerGui.MainGui.MainFrame["Newest Posts"] then
local ClonedPost = player.PlayerGui.MainGui.MainFrame["Newest Posts"].Template
ClonedPost.Parent = player.PlayerGui.MainGui.MainFrame["Newest Posts"]
ClonedPost.Username.Text = "@"..messages[1]
ClonedPost.DisplayName.Text = messages[2]
ClonedPost.Message.Text = messages[4]
ClonedPost.Title.Text = messages[3]
local unique = HttpsService:GenerateGUID(false)
ClonedPost.UniquePostNumber.Text = unique
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size100x100
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
local ProfilePic = ClonedPost.ProfilePicture
ProfilePic.Image = content
------------------------------
local success, errorMessage = pcall(function()
Data_TotalAmount:SetAsync("Key", TotalVal.Value)
end)
if not success then
print(errorMessage)
end
end
------------------------------
TotalVal.Value = TotalVal.Value +1
Data_TotalAmount:SetAsync("Key", TotalVal.Value)
end
end)
SendPost.OnServerEvent:Connect(function(Player:Player, A:TextBox, B)
MessagingService:PublishAsync("SendPost", {Player.Name, Player.DisplayName, Player.MessageString.Value, Player.TitleString.Value})
print(Player.Name)
print(Player.DisplayName)
end)
ChangeData.OnServerEvent:Connect(function(Player, T, M)
Player:WaitForChild("MessageString").Value = M
Player.TitleString.Value = T
warn("Running V1 Of Change Data")
end)
local ds = game:GetService("DataStoreService"):GetDataStore("GlobalValue")
local SERVER_KEY_NAME = "Server"
local success, data = pcall(function()
return ds:GetAsync(SERVER_KEY_NAME)
end)
ds:SetAsync(SERVER_KEY_NAME, TotalVal.Value)
wait(4)
if success then
print(data) -->> the server data
for i, v in pairs(Players:GetPlayers()) do
v.PlayerGui.MainGui.MainFrame.TotalAmount.Text = "Total Amount Of Posts: "..tostring(data)
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.PlayerGui.MainGui.MainFrame.TotalAmount.Text = "Total Amount Of Posts: "tostring(data)
end)
TotalVal:GetPropertyChangedSignal("Value"):Connect(function()
TotalVal.Value = TotalVal.Value -1
ds:SetAsync(SERVER_KEY_NAME, TotalVal.Value)
wait(4)
for i, v in pairs(Players:GetPlayers()) do
v.PlayerGui.MainGui.MainFrame.TotalAmount.Text = "Total Amount Of Posts: "..tostring(TotalVal.Value)
end
end)
CLIENT
local vNumber = "1.1"
local OkToPost = false
warn("Running version "..vNumber.." for RoFeed. Current game name for refrence: "..game.Name..". DevKeia's property!")
--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")
local TweenService = game:GetService("TweenService")
local TextService = game:GetService("TextService")
local InfoTween = TweenInfo.new(0.7, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
--// Events
local SendPost = Events:WaitForChild("SendPost")
local ChangeData = Events:WaitForChild("ChangeData")
local SendSignalToServerPost = Events:WaitForChild("SendFilterSignalToServer")
local SendFilterSignalToClient = Events:WaitForChild("SendFilterSignalToClient")
--// Objects
local MainGui = script.Parent
local MainFrame = MainGui:WaitForChild("MainFrame")
local NotificationFrame = script.Parent.Notification
local PostTitle = MainFrame:WaitForChild("PostTitle")
local PostMessage = MainFrame:WaitForChild("PostMessage")
local PostButton = MainFrame:WaitForChild("PostButton")
local LoadingFrame = script.Parent.Loading
local LoadingNotice = LoadingFrame:WaitForChild("Notice")
LoadingFrame.Visible = true
task.wait(0.5)
LoadingNotice.Text = "Sending Data!"
task.wait(0.5)
LoadingNotice.Text = "Gathering your posts!"
task.wait(1)
LoadingNotice.Text = "Checking the feeds."
task.wait(0.5)
LoadingNotice.Text = "Sending 'Messaging Service' signal!"
task.wait(0.5)
LoadingNotice.Text = "Checking for ReplicatedStorage events..."
task.wait(1)
LoadingNotice.Text = "Loading GUI..."
task.wait(0.5)
LoadingNotice.Text = "Done!"
LoadingFrame:TweenPosition(UDim2.new(0, 0,0, 850))
--// Code
SendFilterSignalToClient.OnClientEvent:Connect(function(M, T)
OkToPost = true
PostMessage.Text = M
PostTitle.Text = T
end)
PostButton.MouseButton1Click:Connect(function()
if PostTitle.Text ~= "TITLE:" then
if PostMessage.Text ~= "WHAT DO YOU WANT TO TELL THE WORLD?" then
SendSignalToServerPost:FireServer(PostTitle.Text, PostMessage.Text)
wait(0.2)
SendFilterSignalToClient.OnClientEvent:Connect(function()
OkToPost = true
end)
wait(0.1)
if OkToPost == true then
NotificationFrame.Visible = true
NotificationFrame.Note.Text = "Sending your data to the server..."
ChangeData:FireServer(PostMessage.Text, PostTitle.Text)
wait(0.3)
NotificationFrame.Note.Text = "Sending the post along all servers..."
SendPost:FireServer(PostTitle.Text, PostMessage.Text)
NotificationFrame.Note.Text = "Posting..."
wait(0.3)
NotificationFrame.Note.Text = "Done!"
wait(0.3)
NotificationFrame.Note.Text = "Adding your post to current Datastore."
wait(1.5)
NotificationFrame.Visible = false
warn("Sucessfully ran V1 of Publishing Messaging Service for RoFeed")
elseif OkToPost == false then
NotificationFrame.Note.Text = "Your post couldn't be filtered. Please only post appropriate posts!"
wait(1.5)
NotificationFrame.Visible = false
end
end
end
end)
EVERYTHING WORKED BEFORE ADDING THE TEXT FILTERING IN.