Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trello Ban Script not banning new players?

Asked by 7 years ago
Edited 7 years ago

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.

1 answer

Log in to vote
1
Answered by 7 years ago

Fixed by removing the chatted event from on player added event. This caused the command only to be ran once.

I added a new event to the workspace and I made a local script fire that even to the server when someone used a command. Can be built upon and optimized.

Also fixed the implemented ban and the player rejoin ban. They simply wasn't implemented.

Another bug I fixed was inserting the player into a banned array.

Good day Sir!

Ad

Answer this question