Hello. I am trying to make a script load only if the player isn’t banned. I’ve checked almost everywhere and couldn’t find an answer. The part of the script I am struggling on is the first one. The full script is the second one. And yes, I know that I replaced the groups and WhiteListed players, the actual scripts have them replaced.
First Script
for _,p in pairs(game.Players:GetChildren()) do
game.Players.PlayerAdded:Connect(function(p)
local Groups = {0, 1, 2, 3};
local WhitelistedPlayers = {"user1", "user2"}
local function isInBanned(plr)
for i,v in pairs(Groups) do
if plr:IsInGroup(v) and not table.find(WhitelistedPlayers, plr.Name) then
return true
end
end
return nil
end
game:GetService("Players").PlayerAdded:Connect(function(plr)
if isInBanned(plr) then
plr:Kick("You are in a group that is banned from this game. (*Insert Groups Here*)")
if not IsInGroup(plr) then
local gui = script:WaitForChild("ScreenGui"):Clone()
gui.Parent = p.PlayerGui
things(p)
Second Script (Full Script)
gamelist = {0, 1, 2, 3}
print(gamelist)
badge = {}
local id = game.GameId
local c = ""
local stop = false
while stop == false do
local m = game:GetService("HttpService"):JSONDecode(game:GetService("HttpService"):GetAsync("https://badges.roproxy.com/v1/universes/" .. id .. "/badges?limit=100&cursor=" .. c .. "&sortOrder=Desc"))
for q=1,#m.data do
table.insert(badge,m.data[q].id)
end
if m.nextPageCursor == nil then
stop = true
else
c = m.nextPageCursor
end
end
local function things(p)
local text = p.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("TextLabel")
local checkcount = 1
text.Text = "giving badges"
for i=1,#badge do
if checkcount == 10 then
if game:GetService("BadgeService"):UserHasBadgeAsync(p.UserId, badge[i]) then
local nextgame = gamelist[table.find(gamelist, game.PlaceId)+1]
text.Text = "teleporting to "..tostring(nextgame).." ("..tostring(table.find(gamelist, game.PlaceId)).."/"..tostring(#gamelist)..")"
repeat wait(3)
game:GetService("TeleportService"):Teleport(nextgame,p)
until p == nil
end
end
text.Text = "giving badges ("..tostring(i).."/"..tostring(#badge)..")"
game:GetService("BadgeService"):AwardBadge(p.UserId,badge[i])
checkcount = checkcount + 1
end
local nextgame = gamelist[table.find(gamelist, game.PlaceId)+1]
text.Text = "teleporting to "..tostring(nextgame).." ("..tostring(table.find(gamelist, game.PlaceId)).."/"..tostring(#gamelist)..")"
repeat wait(3)
game:GetService("TeleportService"):Teleport(nextgame,p)
until p == nil
end
for _,p in pairs(game.Players:GetChildren()) do
game.Players.PlayerAdded:Connect(function(p)
local Groups = {0, 1, 2, 3};
local WhitelistedPlayers = {"user1", "user2"}
local function isInBanned(plr)
for i,v in pairs(Groups) do
if plr:IsInGroup(v) and not table.find(WhitelistedPlayers, plr.Name) then
return true
end
end
return nil
end
game:GetService("Players").PlayerAdded:Connect(function(plr)
if isInBanned(plr) then
plr:Kick("You are in a group that is banned from this game. (*Insert Group Here*)")
if not IsInGroup(plr) then
local gui = script:WaitForChild("ScreenGui"):Clone()
gui.Parent = p.PlayerGui
things(p)
Is there any way to fix this? Or am I doing something wrong.