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

How do I make a in game command to link people?

Asked by 6 years ago

I want to make a script that allows my admins in game to be able to "pull" others. Like, if the person who said the command moves, the person their linked to is dragged with them. I'm brand new to scripting,and I have Khol's Admin Commands. Any ideas?

0
You should attempt it. User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

If you mean like :kill me or :tp others me then here is the code

local admins = {"yourname"}
local prefix = "!"

function isAdmin(player)
    for i,v in pairs(Admins) do
    if v == player.Name then
        return true
    end
    end
    return false
end

function GrabPlayers(speaker, input)
    local collectplayers = {}
    if input:match("^!") then
        return FindPlayers(speaker, input:sub(2), true)
    elseif input == "me" then
        table.insert(collectplayers, speaker)
    elseif input == "all" then FindPlayers = function(speaker, input)
        local collectplayers = {}
        if input:match("^!") then
            return FindPlayers(speaker, input:sub(2), true)
        elseif input == "me" then
            table.insert(collectplayers, speaker)
        elseif input == "all" then
            for _,v in pairs(game:GetService("Players"):GetPlayers()) do
                table.insert(collectplayers, v)
            end
        elseif input == "others" then
            for _,v in pairs(game:GetService("Players"):GetPlayers()) do
                if v ~= speaker then
                    table.insert(collectplayers, v)
                end
            end
        else
            for _,v in pairs(game:GetService("Players"):GetPlayers()) do
                if v.Name:lower():sub(1,#input) == input:lower() then
                    table.insert(collectplayers, v)
                end
            end
        end
        return collectplayers
    end
    for _,v in pairs(game:GetService("Players"):GetPlayers()) do
        table.insert(collectplayers, v)
    end
    elseif input == "others" then
        for _,v in pairs(game:GetService("Players"):GetPlayers()) do
            if v ~= speaker then
                table.insert(collectplayers, v)
            end        
        end
    else        
        for _,v in pairs(game:GetService("Players"):GetPlayers()) do
            if v.Name:lower():sub(1,#input) == input:lower() then
                table.insert(collectplayers, v)
            end
        end
    end
    return collectplayers
end

game:GetService("Players").PlayerAdded:connect(function(player)
    if isAdmin(player) then
            player.Chatted:connect(function(message)
        if message:sub(1,6):lower() == Prefix.."kill " then
            local Target = GrabPlayers(player, message:sub(7))
            for index,target in next,Target do
                if target.Character then
                    if target.Character:FindFirstChildOfClass("Humanoid") then
                    target.Character:FindFirstChildOfClass("Humanoid").MaxHealth = -1000
                target.Character:FindFirstChildOfClass("Humanoid").Health = -1000
                end
            end
            end
        end
        end)
    end
end)

Then if you say !kill me or !kill others, it will kill you or all other players besides you.

0
So, what would I replace to change it from,lets say "kill", to "telaport"? FeatherTheFoxHuman34 0 — 6y
Ad

Answer this question