Hello! To begin with, the script works at first. When I join a server and do ban plrName the player get's put on the Trello, His name and his userID are printed in the console.
But let's say another player joins, I'm not able to ban him untill I rejoin myself. I do not believe the trello api I'm using is needed, But if it is just ask.
------[[[[[[[[[[[[[[[[---->
api = require(game.ServerScriptService.TrelloAPI) -- Require Module
BoardID = api:GetBoardID("NewTest") -- Use module to get BoardID From Trello
ListID = api:GetListID("Ban List",BoardID) -- Use module to get List from BoardID
speakers = {"Robertandy11"} --ADmins
banned = {} -- People I don't like
function checkSpeakers(name) --Test if "speaker" is admin or not
for i,v in pairs(speakers) do
if (string.upper(name) == string.upper(v)) then return true end
end
return false
end
function onChatted(msg, recipient, speaker) -- Command
msg = msg:lower()
if string.sub(msg,1,4) == "ban " then -- If played chatted "ban" then
if game.Players:FindFirstChild(string.sub(msg,5)) ~= nil then
local victim = string.sub(msg,5) -- Find the player after the ban command
local banner = speaker -- Find the one who banned him
local victimid = game.Players:GetUserIdFromNameAsync(victim) -- Get Banned userId
print(victimid)
print(victim)
api:AddCard((victim..":"..victimid) , "Banned", ListID) --Use API to add victim to trello
local removedpl = game.Players:FindFirstChild(victim)
removedpl:Destroy()
end
end
end
function onPlayerEntered(newPlayer)
-- remove banned player if they try to come back in
for i,v in pairs(banned) do
if (v:lower() == newPlayer.Name:lower()) then
newPlayer:Remove()
end
end
if checkSpeakers(newPlayer.Name) then
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
print("Ban Commands Loaded!")
Edit : All this script is supposed to do is create a Card on the banlist on trello, which it does But not for the players that join after the Admin/Moderator. The script that takes care of game-wide banning people and syncing bans is alerady done.
