Hello i’m not good at scripting so i got a problem with a board text changer script, i did filtering text thing but it still wont work did i do something wrong in the code?
code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")
--rwor is a Text from a textbox
Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
local est = game:GetService("Chat"):FilterStringForBroadcast(rwor, player)
if board == "Board" then
game.Workspace.BOARD1.ewqeqw.Message.Text = est
game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
elseif board == "Board2" then
game.Workspace.BOARD2.ewqeqw.Message.Text = est
game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
elseif board == "Board3" then
game.Workspace.BOARD3.ewqeqw.Message.Text = est
game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
end
end)
I finally got solution by @MallocByte
Here fixed code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")
Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
local estp = game:GetService("TextService"):FilterStringAsync(rwor, player.UserId)
local est = estp:GetNonChatStringForBroadcastAsync()
if board == "Board" then
game.Workspace.BOARD1.ewqeqw.Message.Text = est
game.Workspace.BOARD1.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD1.ewqeqw.Neim.Text = PlayerName
elseif board == "Board2" then
game.Workspace.BOARD2.ewqeqw.Message.Text = est
game.Workspace.BOARD2.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD2.ewqeqw.Neim.Text = PlayerName
elseif board == "Board3" then
game.Workspace.BOARD3.ewqeqw.Message.Text = est
game.Workspace.BOARD3.ewqeqw.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
game.Workspace.BOARD3.ewqeqw.Neim.Text = PlayerName
end
end)
What’s wrong exactly? Is the filtered text not well-filtered or is there an error. The wiki says that :FilterStringForBroadcast() has some limitation compared to :FilterStringAsync(), try this one instead maybe.
Also the script can be easily shortened to something like this
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("SendSignal")
--rwor is a Text from a textbox
Event.OnServerEvent:Connect(function(player, rwor, PlayerName, PlayerID, board)
local est = game:GetService("Chat"):FilterStringForBroadcast(rwor, player)
local obj = game.Workspace[string.upper(board)].ewqeqw
obj.Message.Text = est
obj.Avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..PlayerID.."&width=420&height=420&format=png"
obj.Neim.Text = PlayerName
end)
FilterStringAsync is what you need to use on the server. FilterStringForBroadcast is deprecated for the client side and should not be used on the server.
This is different from ChatService, rather this is newer and is a part of TextService
Cheers
EDIT: The function returns an instance. To get the string, use this on that instance.
Make sure that you have a correct spelling of the word ‘Board’ because you don’t use any string.lower or anything else might be a problem that it doesn’t find correct string and operation stops. I also heard that there were many problems with this FilterStringForBroadcast so try using FilterStringAsync for the server-side. I just read on the wiki that it has to be used on server-side, so make sure you use it.
@MallocByte FilterStringAsync is also deprecated on client-side and it shouldn’t be used anymore there. It has to be used on the server-side like you said, just to mention.