What I’m trying to acomplish is fairly simple, when a Player types in the TextBox and whatever they type it will get filtered via the ChatService before it’s displayed on a Part via a TextLabel.
My main question is how do I fact check this, if a Player types in the TextBox is there a way to confirm if there is string in that TextBox and when they press the SubmitButton it would automatically be changed on the TextLabel.
Here’s the code:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local ChatService = game:GetService("Chat")
local RemoteEvent = game.ReplicatedStorage.BoothEvent
local BoothGui = game.StarterGui.BoothGui
local LocalPlayer = Players.LocalPlayer
local PlayerBoothGui = LocalPlayer.PlayerGui:WaitForChild("BoothGui")
RemoteEvent.OnClientEvent:Connect(function()
PlayerBoothGui.Enabled = true
PlayerBoothGui.Frame.BackgroundTransparency = 0
local SubmitButton = PlayerBoothGui.Frame.SubmitButton
local CloseButton = PlayerBoothGui.Frame.CloseButton
local BoothText = game.Booth.Header.SurfaceGui.FrameGui.TextGui.Text
CloseButton.MouseButton1Click:Connect(function()
if PlayerBoothGui.Enabled == true then
PlayerBoothGui.Enabled = false
game.ReplicatedStorage.ChatEvent.OnServerEvent:Connect(function(player, BoothText)
ChatService:FilterStringForBroadcast(BoothText, player)
-- Here I'd go through the actual changing of the text
end)
end
end)
print("RemoteEvent fired Successfully")
end)
Yeah that’s what I ended up doing but I had an error with the chat filtering.
Here’s the code.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local ChatService = game:GetService("Chat")
local RemoteEvent = game.ReplicatedStorage.BoothEvent
local BoothGui = game.StarterGui.BoothGui
local LocalPlayer = Players.LocalPlayer
local PlayerBoothGui = LocalPlayer.PlayerGui:WaitForChild("BoothGui")
RemoteEvent.OnClientEvent:Connect(function()
PlayerBoothGui.Enabled = true
PlayerBoothGui.Frame.BackgroundTransparency = 0
local SubmitButton = PlayerBoothGui.Frame.SubmitButton
local CloseButton = PlayerBoothGui.Frame.CloseButton
local TextBox = BoothGui.Frame.Frame.TextBox
local BoothText = game.Workspace.Booth.Header.SurfaceGui.Frame.TextLabel.Text
game.ReplicatedStorage.ChatEventFilter.OnServerEvent:Connect(function(player, BoothText)
ChatService:FilterStringForBroadcast(BoothText, player)
SubmitButton.MouseButton1Click:Connect(function()
if TextBox.Text ~= nil then --
BoothText = TextBox.Text
if TextBox == BoothText then
if PlayerBoothGui.Enabled == true then
PlayerBoothGui.Enabled = false
print("Text Changed")
end
end
end
end)
end)
CloseButton.MouseButton1Click:Connect(function()
if PlayerBoothGui.Enabled == true then
PlayerBoothGui.Enabled = false
end
end)
end)
Keep in mind I know that it’s a Local Script and the code needs to be in a server script but my main issue now is that how do I fix that lol do I simply use the filtering chat server in a server script and then fact check the texting because I also want to make it where when a player finishes typing it’s done by a Submit button.
game.ReplicatedStorage.ChatEventFilter.OnServerEvent:Connect(function(player, BoothText)
ChatService:FilterStringForBroadcast(BoothText, player)
SubmitButton.MouseButton1Click:Connect(function()
if TextBox.Text ~= "" then
BoothText = TextBox.Text
if TextBox == BoothText then
if PlayerBoothGui.Enabled == true then
PlayerBoothGui.Enabled = false
print("Text Changed")
end
end
end
Do I seriously have to make a whole seperate script just to filter the text on the server.