Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago
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?

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? starmaq 1290 — 5y
0
i have to do it like that, if the if statement returns false it prints that Cald_fan 26 — 5y
0
The print will run no mater if the statement runs use an else User#5423 17 — 5y
0
well the statement still returns false Cald_fan 26 — 5y
View all comments (7 more)
0
run print(v:lower() == plr.Name:lower()) User#5423 17 — 5y
0
i did that in the if statement Cald_fan 26 — 5y
0
meaning it does string:lower() in the if statement Cald_fan 26 — 5y
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. User#5423 17 — 5y
0
then i have to use methods and do more stuff because i get this info from a trello board Cald_fan 26 — 5y
0
Thats your call to make. User#5423 17 — 5y
0
eh ill do it Cald_fan 26 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question