Well I made an admin system and it works pretty well, although the banning situation… not so well- Whenever I press the ‘ban’ button after typing in the username and reason it doesnt ban, although the unban works.
Local script inside the ban button:
script.Parent.Parent.BanPresser.MouseButton1Click:Connect(function()
local reason = script.Parent.Parent.ReasonBox.Text
local plrtoban = script.Parent.Parent.UsernameBox.Text
if reason.Text ~= "" and plrtoban ~= "" then
game.ReplicatedStorage:WaitForChild("BAU"):FireServer(plrtoban, reason, "Ban")
end
end)
Script inside serverscriptspace:
local admins = {"saouvs"}
local ds = game:GetService("DataStoreService"):GetDataStore("BAU")
game.Players.PlayerAdded:Connect(function(plr)
local data = ds:GetAsync(plr.UserId)
if data then
local IsAdmin = false
for i, v in pairs(admins) do
if v == plr.UserId then
IsAdmin = true
game.StarterGui.samsadmin.BasicModeration:Clone().Parent = plr.PlayerGui
end
end
if IsAdmin == false then
if data[1] == true then
plr:Kick("You have been banned from this game, reason:"..data[2])
end
end
end
end)
game.ReplicatedStorage:WaitForChild("BAU").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.Parent[plrtoban]:Kick("You have been banned from this game, 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:GetNameFromUserIdAsync(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)```
I'll try any and all solutions and suggestions, thank you.
local IsAdmin = false
if plr:GetRankInGroup(8176838) >= 210 then
IsAdmin = true
game.StarterGui.samsadmin.BasicModeration:Clone().Parent = plr.PlayerGui
end
if IsAdmin == false then
if data[1] == true then
plr:Kick("You have been banned from this game, reason:"..data[2])
end
end
and OnServerEvent
local players = game:GetService("Players")
game.ReplicatedStorage:WaitForChild("BAU").OnServerEvent:Connect(function(plr, plrtoban, reason, ban)
if plr:GetRankInGroup(8176838) >= 210 then
if ban == "Ban" 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 game, reason: "..reason)
ds:SetAsync(game.Players[plrtoban].UserId, {true, reason})
else
print("This player is an admin")
end
else
local Id = players:GetUserIdFromNameAsync(plrtoban)
if Id ~= plr.UserId then
ds:SetAsync(Id, {true, reason})
print(plrtoban.." has been banned!")
end
end
elseif ban == "Unban" then
local Id = players:GetUserIdFromNameAsync(plrtoban)
ds:RemoveAsync(Id)
print(plrtoban.." has been unbanned!")
end
end
end)