I have tried to make a Find Player function to where it'll find the Player(s), for instance, if a player were to type 'kill/all', it would kill all players, but when I try to do it, the script sometimes Errors and says something like Attempt to compare 'str' (a userdata value), or Attempt to compare 'str' (a nil value), so, I'm stumped on how I can do it. :P Here is in attempt script I tried [To test before asking what I'm supposed to do, and what I'm doing wrong];
local Matches = 0
local function findPlr(plr,str)
if str == "all" then
return plr == game.Players:GetPlayers()
end
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower():find(plr:lower()) then
Matches = Matches + 1
return (v)
end
end
end
findPlr(nil,"all")
print(Matches) --This just keeps saying 0 :/ So confused >_<
And heres a original 'Find Player' function I used;
local function FindPlayer(plr)
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower():find(plr:lower()) == 1 then
return (v)
end
end
return nil
end
FindPlayer("Player")

1 comment
Lol, Thanks man! It took me a little bit to figure out, but I got finally got the thing to work thanks to your help! :)