The following code always returns nil which is there error(there is more into the script but this is what I need to be fixed)
function SearchPlr(text) for i, v in next,game.Players:GetPlayers() do if string.find(v.Name,"^"..text) then return v.Name:lower() end end end
No matter what I do v:lower() or v.Name:lower() it always returns nil =/
You should use a lowercase version of both the search text and the text to be searched in:
if v.Name:lower():find( "^" .. text:lower() ) then
Though, instead of using find
and the caret, it might be wiser to just use substrings:
if v.Name:sub(1, #text):lower() == text:lower() then
Sure, I can.
function SearchPlr(Text) --Your function. for i,v in pairs(game.Players:GetPlayers()) do --Gets all the players in the game. if v.Name:lower():find(Text:lower()) or v.Name:lower() == Text:lower() then --See's if the player's name matches the Text or has part of the Player name as the text. return v.Name:lower() --Returns the player name lowered. end end end