I tried this rewrite, but it does not seem to give any output or reactions at all.
Summary
local serveruri = 'https://newstargeted.com/mas/Bans.php?Bans='
local http = game:GetService('HttpService')
local function removeFromGame(player)
player:Kick("You have been kicked for exploiting")
end
game.Players.PlayerAdded:Connect(function(player)
local success, result = pcall(function()
return http:GetAsync(serveruri .. player.UserId)
end)
if not success then
local response = {
error = "An error occurred when connecting to the website: " .. result,
value = nil
}
return response
end
result = http:JSONDecode(result)
if result.error then
local response = {
error = result.error,
value = nil
}
return response
elseif result.banned == "True" then
removeFromGame(player)
local response = {
error = nil,
value = player.Name .. ' is banned and has been removed from the game.'
}
return response
elseif result.banned == "False" then
local response = {
error = nil,
value = player.Name .. ' is not banned.'
}
return response
else
local response = {
error = 'Unknown response',
value = nil
}
return response
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, result = pcall(function()
return http:GetAsync(serveruri .. player.UserId)
end)
if not success then
local response = {
error = "An error occurred when connecting to the website: " .. result,
value = nil
}
return response
end
result = http:JSONDecode(result)
if result.error then
local response = {
error = result.error,
value = nil
}
return response
elseif result.banned == "True" then
local response = {
error = nil,
value = player.Name .. ' is banned and has been removed from the game.'
}
return response
elseif result.banned == "False" then
local response = {
error = nil,
value = player.Name .. ' is not banned.'
}
return response
else
local response = {
error = 'Unknown response',
value = nil
}
return response
end
end)
while true do
wait(10)
for _, player in pairs(game.Players:GetPlayers()) do
local success, result = pcall(function()
return http:GetAsync(serveruri .. player.UserId)
end)
if not success then
local response = {
error = "An error occurred when connecting to the website: " .. result,
value = nil
}
return response
end
result = http:JSONDecode(result)
if result.error then
local response = {
error = result.error,
value = nil
}
return response
elseif result.banned == "True" then
removeFromGame(player)
local response = {
error = nil,
value = player.Name .. ' is banned and has been removed from the game.'
}
return response
elseif result.banned == "False" then
local response = {
error = nil,
value = player.Name .. ' is not banned.'
}
return response
else
local response = {
error = 'Unknown response',
value = nil
}
return response
end
end
end
local HttpService = game:GetService("HttpService")
serveruri = 'https://newstargeted.com/mas/Bans.php?Bans='
--serveruri = 'https://mas.newstargeted.com/Bans.php?Bans='
function RemoveFromGame(Player)
Player:Kick("You have been Kicked for exploiting") -- you can replace this with your own method of kicking, e.g. a crash script
end
function safeReq(url)
local success, result = pcall(function()
return HttpService:GetAsync(url)
end)
if success then
return true, result
else
return false, result
end
end
function processStatus(statusCode, result)
if statusCode == 200 then
-- process result
else
-- handle error
end
end
game.Players.PlayerAdded:connect(function(Player)
local success, result = safeReq(serveruri..Player.userId)
if not success then
print("Error making request: " .. result)
else
processStatus(200, result)
if result["error"] then
print(result["error"])
elseif result["banned"] == "True" then
RemoveFromGame(Player)
print('Player "'..Player.Name..'" is banned and therefore removed from the game.')
elseif result["banned"] == "False" then
print('Player "'..Player.Name..'" is not banned.')
else
print('Unkown response')
end
end
end)
while wait(10) do
for _,Player in pairs (game.Players:GetPlayers()) do
local success, result = safeReq(serveruri..Player.userId)
if not success then
print("Error making request: " .. result)
else
processStatus(200, result)
if result["error"] then
print(result["error"])
elseif result["banned"] == "True" then
RemoveFromGame(Player)
print('Player "'..Player.Name..'" is banned and therefore removed from the game.')
elseif result["banned"] == "False" then
print('Player "'..Player.Name..'" is not banned.')
else
print('Unkown response')
end
end
end
end
print(newPlayer.Name..", If you see this, it means that the RemoteBan works.")