I have a ban GUI and i want to filter the reason text but no scripts i try work.
Script in serverscriptservice:
local admins = {1822194589, 883317228} -- Add your id here
local ds = game:GetService("DataStoreService"):GetDataStore("Bans/Unbans")
game.Players.PlayerAdded:Connect(function(plr)
local data = ds:GetAsync(plr.UserId)
local IsAdmin = false
for i,v in pairs(admins) do
if v == plr.UserId then
IsAdmin = true
local clone = script.BanGui:Clone()
clone.Parent = plr.PlayerGui
end
end
if data then
if IsAdmin == false then
if data[1] == true then
plr:Kick("You have been banned from this experience. Reason: "..data[2])
end
end
end
end)
game.ReplicatedStorage:WaitForChild("Ban/Unban").OnServerEvent:Connect(function(plr, plrtoban, reason, ban)
if ban == "Ban" then
for i,v in pairs(admins) do
if plr.UserId == v then
if game.Players:FindFirstChild(plrtoban) then
if game.Players[plrtoban].UserId ~= plr.UserId then
print(plrtoban.." has been banned!")
game.Players[plrtoban]:Kick("You have been banned from this experience. Reason: "..reason)
ds:SetAsync(game.Players[plrtoban].UserId, {true, reason})
else print("This player is an admin!")
end
else
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(plrtoban)
if Id ~= plr.UserId then
ds:SetAsync(Id, {true, reason})
print(plrtoban.." has been banned!")
end
end
end
end
elseif ban == "Unban" then
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(plrtoban)
ds:RemoveAsync(Id)
print(plrtoban.." has been unbanned!")
end
end)
If this GUI is only to be used by moderators which must be trusted personnel then clearly its not a huge deal if it’s not filtered as you can trust they won’t put a bad reason. Also log all admin actions so if a mod does abuse then you can show roblox it was the person and not you.
This is unsafe and is a dangerous practice. Just because someone is “trusted” does not mean you should not moderate the input they may be sending to other players.
Its just for me and my friend who is a developer and i trust him but i want to see if it is possible just to be safe since roblox says the games will be taken down for review if the text isnt filtered and i want to take action now to keep myself safe in the future
yea I had it filter the reason string right before the kick the player code but it just broke the whole GUI
oh wait I used filterstringasync lemme try this one
could I put that above the kicking part if game.Players[plrtoban].UserId ~= plr.UserId then print(plrtoban.." has been banned!") game.Players[plrtoban]:Kick("You have been banned from this experience. Reason: "..reason) ds:SetAsync(game.Players[plrtoban].UserId, {true, reason}) and then set reason as the filtered thing
When you set the ban reason, make sure to pcall the function then set the reason in the datastore. If the filter fails then just set the reason to ERROR.
local success, errorMessage = pcall(function()
filteredreason = game:GetService("TextService"):FilterStringAsync(reason, plr.UserId)
filteredreason = filteredreason:GetNonChatStringForBroadcastAsync()
end)
if success then
game.Players[plrtoban]:Kick("You have been banned from this experience. Reason: "..filteredreason)
ds:SetAsync(game.Players[plrtoban].UserId, {true, reason})
end
local String -- Used for later.
local FilterSuccess, FilterResult = pcall(function()
return TextService:FilterStringAsync(
StringToFilter,
PlayerUserId
)
end)
if (FilterSuccess)
then
String = FilterResult:GetNonChatStringForUserAsync(PlayerUserId) or ''
print(String)
end
I’m doing it within the admin script which is in serverscriptservice that I provided in the original post I’ll link the code when I can bc I’m not at my computer rn