try using string.find(PATTERN,USERNAME)
full code version
local usernameshort = “test”
for i,v in ipairs(game.Players:GetPlayers())
if string.find(v.Name,test) then
bla bla
end
end
local command = “;to mro”
local pattern = string.sub(command,5)
for i,v in ipairs(game.Players:GetPlayers()) do
local alllow = string.lower(v.Name)
if string.find(alllow,pattern) then
warn(v.Name)
end
end
it prints out my username which is on the pattern “mro” which completes as mroofman_rblx also i added lowering so if you type ;to MroOfmAn_RbLx it still teleports to me if you should modify it so it works on your script
wait i might of not have been so clear about what i was trying to do i’m tyring to make it so it does this but for each player so for example someone called noob12345
i would just have to do like ;to noob
( i’m not that good in stuff like this so excuse me if you allready did that)
also if you want to split the command and the players username do: string.sub(";to ohMyGoodness9",5) --this gives the only username change string.find("OhMyGoodness9","OhMy") – this is for the pattern
game.Players.PlayerAdded:Connect(function(player) -- Player Joined A Game
if table.find(Admins,player.UserId) then -- Check If Admin
player.Chatted:Connect(function(msg) -- Admin Chatted
local lowmessage = string.lower(msg) -- Lower the message
if string.find(lowmessage,";to") then -- Check if it has ;to command
local victimplayer = string.sub(lowmessage,5) -- Get the player name from the message
if string.len(victimplayer) >= 2 then -- Check if the username has more then 2 letters since if a missclick happens we don't want any bad thing happening right?
for i,v in ipairs(game.Players:GetPlayers()) do -- Get all players from the game
if v ~= player then -- Check if the player we are going to teleport to is a admin if not continue
local lowplayername = string.lower(v.Name) -- Lower Players Username
if string.find(lowplayername,victimplayer) then -- Check Patern
player.Character.Torso.CFrame = v.Character.Torso.CFrame -- Teleporting Weeeeeeee
end
end
end
end
end
end)
end
end)
local function getplyr(plr, nme)
for _, p in pairs(game.Players:GetPlayers()) do
if (p.Name:sub(1, #nme):lower() == nme:lower()) then
if p.Name ~= plr.Name then
return p
end
end
end
end
Made admin before, here is what I did and still works to this day.
If you have any questions about it, ask away.
Explanation: “person” is a string value that is split up by string:split(). It is the second value in the string. Then all you do is check every player on the server and if there is a match, you change “person” to the player’s full username and send it over to the server.
My grammar isn’t the best, sorry.
for _,v in ipairs(game:GetService("Players"):GetPlayers()) do
if v.Name:match(person) then
person = v.Name
end
end
local player = game.Players:FindFirstChild(person)
Should look like this.
Edit: This version is case-sensitive and I am yet to know how to make it not.
this is uh a really old reply i forgot about this topic but i later found it again by looking how to do the same thing again lol anyways i’ve tried this and it works i’m just wondering are you able to do
local victimplayer = msg:split(" ")[2]
instead of doing local victimplayer = string.sub(lowmessage,5) since i’m more familiar with the first option