Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make a kick script but not require the full name?

I know how to make a kick script, but I am stumped on how to make it not need a full username to kick a player (chat command)

1 answer

✓ Accepted answer

Use string.match(...)


function fuzzyKick(targetName)
    players = game:GetService("Players")
    matches = {}

    for i, v in pairs(players) do
        if string.match(v.Name, targetName) then
            matches[#matches + 1] = v
        end
    end
    
    if #matches == 1 then
        v:Kick()
    elseif #matches == 0 then
        -- report no matches
    else
        -- report multiple matches
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.