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

How can I remove the need of typing the full name of the target player in a chat command?

Asked by 5 years ago

I am making an admin script for my game.

It is working fine, but I want to remove the need of typing the target player's full name. I want it so we only need to type like half of the name or less, and case insensitive.

Here is the script:

local admins = {"StrategicPlayZ", "1_7z", "Player1"}

local onPlayerAdded = function(player)
    for _, name in pairs(admins) do
        if player.Name == name then
            player.Chatted:Connect(function(msg)
                if string.sub(msg, 1, 5) == "kill/" and game.Players:FindFirstChild(string.sub(msg, 6)) then
                    game.Players:FindFirstChild(string.sub(msg, 6)).Character:BreakJoints()
                end
            end)
        end
    end
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

Please explain me how I can do this. I don't want to just copy paste the script.

Thanks in advance!

Answer this question