Recently i’ve made a ban script, which obviously checks if you’re banned and then kicks the player, the problem is that i am trying to check if the players UserId
is not equal to the CreatorsId
or if the player has not the rank Admin
, if so the server will kick the player, if they do have the Admin
rank or if the player is the creator it won’t kick them, the problem is that even with the Admin
rank and being the creator it still kicks me out of the game, i honestly do not know how i would it stop it from kicking the creator or an administrator out of the game.
Players.PlayerAdded:Connect(function(Player)
local BanData
local Success,ErrorMessage = pcall(function()
BanData = BanDatastore:GetAsync(BanKey..Player.UserId)
end)
local RankData = RankDatastore:GetAsync(RankKey..Player.UserId)
if Success then
if not BanData then
local Success,ErrorMessage = pcall(function()
BanDatastore:SetAsync(BanKey..Player.UserId,{IsBanned = false,Moderator = "",Reason = "",BannedAt = 0})
end)
if not Success then
warn("Error: "..ErrorMessage)
end
elseif BanData then
if BanData.IsBanned then
if Player.UserId ~= game.CreatorId or RankData ~= "Admin" then
Player:Kick("\nYou've been banned out of ".. game.Name.."\nModerator: ".. BanData.Moderator.."\nReason: ".. BanData.Reason.."\n\n[ Banned at: ".. os.date('%c',BanData.BannedAt).." ]")
end
end
end
elseif not Success then
warn("Error: "..ErrorMessage)
end
end)