I have a ban GUI and I want to filter the reason text and I tried the Roblox tutorial on filtering but it just broke my entire system.
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)