Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this if statement return false when the values are the same?

mentors = {"Enchanted4Dan","officialpm","AnuCat","Cald_fan","Alexoct"}
for i,v in ipairs(mentors) do 
	print(v..":  "..plr.Name) -- so i can see if the values are the same, which they are
	print(type(v)..":   "..type(plr.Name)) -- so i can see if the value types are the same, which they are
       	if v:lower() == (plr.Name:lower()) then
		print("success")
            	server.Remote.MakeGui(v,"MentorProgram",{
			StudentsCards = StudentsCards,
			MentorCards = MentorCards,
			Player = plr
		})
	else
		print(v.." and "..plr.Name.." are not equal") -- tells me they are not the same, when they are
        end
end

when it prints it prints this, this for my name

:: Kronos :: Cald_fan : Cald_fan

:: Kronos :: string: string

:: Kronos :: Cald_fan and Cald_fan are not equal

why doesnt the if statement return true?

11 comments

0

Cald_fan and Cald_fan are not equal is getting printed outside the if statement so it will always print it no matter what, is it printing success?

0

i have to do it like that, if the if statement returns false it prints that

0

The print will run no mater if the statement runs use an else

0

well the statement still returns false

0

run print(v:lower() == plr.Name:lower())

0

i did that in the if statement

0

meaning it does string:lower() in the if statement

0

tbh I would never use name in the first place. Use the players id it is far better than checking for a name as a player can change their name.

0

then i have to use methods and do more stuff because i get this info from a trello board

0

Thats your call to make.

0

eh ill do it

1 answer

Thanks to @kingdom5 as he said said i should use user id and it fixed the problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.