✓ Accepted answer
finding a way to find a player by partial is relatively easy:
function findPlayer(msg)
local msg = msg:lower()
for _, v in pairs(game.Players:GetPlayers()) do
local name = v.Name:lower():sub(0, msg:len())
if name == msg then
return v
end
end
return nil
end
This works in the example:
function findPlayer(msg)
local msg = msg:lower()
for _, v in pairs(game.Players:GetPlayers()) do
local name = v.Name:lower():sub(0, msg:len())
if name == msg then
return v
end
end
return nil
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
print(findPlayer(msg).Name)
end)
end)
3 comments
use string.match()
what do you mean by typing in, the user typing in chat or in a textbox?
I mean in a text box which then changes a value to the text they typed.