I made a Plate System to Cars but the text label Don’t make tags when the player write Words that break the rules of Roblox
how ICan fix this
The system runs in script and event
I made a Plate System to Cars but the text label Don’t make tags when the player write Words that break the rules of Roblox
how ICan fix this
The system runs in script and event
Read about FilterStringAsync here!
It should be handled on the server and Wrapped in a pcall as mentioned about. Here is an example that in given in the doc:
local TextService = game:GetService("TextService")
local filteredText = ""
local success, errorMessage = pcall(function()
filteredTextResult = TextService:FilterStringAsync(text, fromPlayerId)
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
-- Put code here to handle filter failure
end
i do this but i got error code
game.ReplicatedStorage.Garag.Plate.OnServerEvent:Connect(function(Plr,TextPlate)
local Car = game.Workspace:WaitForChild(Plr.Name.."sCar")
local BodyModel = Car.Body
local PlatePart = BodyModel:WaitForChild("PlateParts")
local TextLabel = PlatePart.Plates.SurfaceGui.TextLabel
local s,e = pcall(function()
TextPlate = TextService:FilterStringAsync(TextPlate,Plr.UserId)
end)
if not s then warn(e) end
if Plr.leaderstats["$"].Value >= 5000 then
Plr.leaderstats["$"].Value = Plr.leaderstats["$"].Value - 5000
TextLabel.Text = TextPlate
end
end)
Line 44
What line is the error mentioning
Try tostring(TextPlate) whenever you want to use it as a string. As it does mention that FilterAsync Returns a instance (It returns a TextFilterResult Instance)
game.ReplicatedStorage.Garag.Plate.OnServerEvent:Connect(function(Plr,TextPlate)
local Car = game.Workspace:WaitForChild(Plr.Name.."sCar")
local BodyModel = Car.Body
local PlatePart = BodyModel:WaitForChild("PlateParts")
local TextLabel = PlatePart.Plates.SurfaceGui.TextLabel
local s,e = pcall(function()
TextPlate = TextService:FilterStringAsync(TextPlate,Plr.UserId):GetChatForUserAsync(Plr.UserId)
end)
if not s then warn(e) end
if Plr.leaderstats["$"].Value >= 5000 then
Plr.leaderstats["$"].Value = Plr.leaderstats["$"].Value - 5000
TextLabel.Text = TextPlate
end
end)
its work but he don’t filtering text
No chat filtering is applied in studio. Only works if you play via roblox player.
i know and im in the game and its same
can you joine me?
game link
Nope and my bad. I missunderstood what FilterStringAsync() does as its been a bit. You see to take the result from the Filter, and Apply TextFilterResult:GetNonChatStringForBroadcastAsync() Via a pcall. Like this:
local textObject = nil
local filteredMessage = nil
local Message = ""
local success, errorMessage = pcall(function()
textObject = TextService:FilterStringAsync(Message, fromPlayerId)
end)
if success then
local successFilter, errorMessage = pcall(function()
filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
end)
if successFilter then
print(filteredMessage)
end
Roblox does write it better for a system like this, with 2 functions:
local function getTextObject(message, fromPlayerId)
local textObject
local success, errorMessage = pcall(function()
textObject = TextService:FilterStringAsync(message, fromPlayerId)
end)
if success then
return textObject
elseif errorMessage then
print("Error generating TextFilterResult:", errorMessage)
end
return false
end
local function getFilteredMessage(textObject)
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
end)
if success then
return filteredMessage
elseif errorMessage then
print("Error filtering message:", errorMessage)
end
return false
end
--My own example of using these functions roblox gave as a test
game.players.PlayerAdded:Connect(function(plr)
local StringMessage = "Player: "..plr.Name.." Has joined the game!"
local GetObject = getTextObject(StringMessage, plr.UserId)
local FilterResult = getFilteredMessage(GetObject)
print(FilterResult)
end)
game.ReplicatedStorage.Garag.Plate.OnServerEvent:Connect(function(Plr,TextPlate)
local Car = game.Workspace:WaitForChild(Plr.Name.."sCar")
local BodyModel = Car.Body
local PlatePart = BodyModel:WaitForChild("PlateParts")
local TextLabel = PlatePart.Plates.SurfaceGui.TextLabel
local s,e = pcall(function()
textObject = TextService:FilterStringAsync(TextPlate,Plr.UserId)
end)
if s then
local successFilter,errorr = pcall(function()
filteredMessage = textObject:GetNonChatStringForBroadcastAsync()
end)
if successFilter then
if Plr.leaderstats["$"].Value >= 5000 then
Plr.leaderstats["$"].Value = Plr.leaderstats["$"].Value - 5000
TextLabel.Text = filteredMessage
end
end
end
end)
done its work Thanks bro
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.