Getting Object From Nickname

I’ve got this function that is meant to return the player object when passed the nickname. There’s two players on the server : Semajnad and Feahlyx. When SGNAdminSit.GetObjectFromNick( “feahlyx” ) is used it doesn’t work. However if I take out return v and return false, it does work?

Can anyone point out what I’m doing wrong?




function SGNAdminSit.GetObjectFromNick( nick )
	for k, v in pairs(player.GetAll()) do
		if string.lower(v:Nick()) == nick then
			print("THIS WORKED")
			return v
		else
			print("Not it " .. v:Nick() )
			return false
		end
	end
end





else
			print("Not it " .. v:Nick() )
			return false

Remove this bit.

Return false breaks the loop. ( Does the same thing as break keyword )
In your case only the loop would always go over 1 player only.

Move the return false to the very end of the function.

Damn, that’s good to know! That explains why when I printed the names of the player.GetAll() loop it only ever printed one! Thanks!