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

Will this ban script work?

Asked by
IcyEvil 260 Moderation Voter
9 years ago

Here is the Portion of the script I dont know will work, Because I dont know how to make it to where if someone is in a table kick them on join.

if msg:sub(1,4) == "ban " then
    vic = msg:sub(1,9)
    m = Instance.new("Message")
    m.Parent = game.Workspace
    m.Text = (vic.Name.."Has Been Banned")
    wait(BanTime)
    m:Destroy()
    table.insert(vic, bans)
    game.Players.PlayerAdded:connect(function(vic)
    if vic.Humanoid.Health == 100 then
        vic:Kick()
    end
    end)
end

full script

admins = {"amegaman"}
bans = {""}
Time = 15
BanTime = 15
for i,v in pairs(IsAdmin) do
    return wait(Time)
end

if msg:sub(1,4) == "msg " then
    m = Instance.new("Message")
    m.Parent = game.Workspace
    m.Text = (Player.Name.."Says"..Player.Chatted)
    wait(Time)
    m:Destroy()
end

if msg:sub(1,4) == "ban " then
    vic = msg:sub(1,9)
    m = Instance.new("Message")
    m.Parent = game.Workspace
    m.Text = (vic.Name.."Has Been Banned")
    wait(BanTime)
    m:Destroy()
    table.insert(vic, bans)
    game.Players.PlayerAdded:connect(function(vic)
    if vic.Humanoid.Health == 100 then
        vic:Kick()
    end
    end)
end

2 answers

Log in to vote
1
Answered by 9 years ago

Have you tried it yet?

1
No, But I have a Very good feeling it will kick everyone who has a health percentage of 100... IcyEvil 260 — 9y
Ad
Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago
admins = {"amegaman"}
bans = {""}
Time = 15
BanTime = 15
--[[for i,v in pairs(IsAdmin) do
    return wait(Time)
end]] --This code doesn't appear to do anything. What's its purpose?

Game.Player.PlayerAdded:connect(function(plr) -- There are  a lot of edits in this, please ask if you don't understand any of them.
    wait() -- So that the Player has a chance to load fully, before kicking them if they are banned.
    for _, v in ipairs(bans) do
        if v == plr.Name then
        plr:Kick()
    end
    for _, v in ipairs(admins) do
        if v == plr.Name then
            plr.Chatter:connect(function(msg)
                msg = msg:lower() --small scrubbing, makes it easier to compare stuff
                if msg:sub(1,4) == "msg " then
                    m = Instance.new("Message")
                    m.Parent = game.Workspace
                    m.Text = plr.Name .. "Says" .. msg:sub(5)
                    wait(Time)
                    m:Destroy()
                end

                if msg:sub(1,4) == "ban " then
                    vic = Game.Players:FindFirstChild(msg:sub(5))
                    if vic then
                        m = Instance.new("Message")
                        m.Parent = game.Workspace
                        m.Text = (vic.Name .. "Has Been Banned")
                        wait(BanTime)
                        m:Destroy()
                        table.insert(bans, vic.Name)
                        vic:Kick()
                    end
                end
            end)
            break
        end
    end
end)

Answer this question