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

Even though the strings are the exact same, I get the else statement in the output, Why?

Asked by 5 years ago

So i'm trying to compare strings and I'm confused on why this outputs as "uh..oh.." when they are the exact same???

nombre = "CHOCO73887"
if plr:GetPlayers()[1] == nombre then
    print ("no duh...")
else
    print("uh...oh...")
end

(as you can tell by my account, my roblox name is CHOCO73887) Can anyone help solve this? Thanks in advance

0
You're comparing the player object to the the string. Just replace it with plr:GetPlayers()[1].Name == nombre. User#29813 0 — 5y
0
This worked! Thank you so much! Choco73887 2 — 5y
0
I'm assuming that "plr" is a variable representing the "Players" service. User#29813 0 — 5y
0
Also, np. User#29813 0 — 5y

1 answer

Log in to vote
0
Answered by
IcyMizu 122
5 years ago
Edited 5 years ago

So u actually have to do this in a for loop if im right

local nombre = "CHOCO73887"
for i , v in pairs (game.Players:GetPlayers())do -- loops trough players
    if v == nombre then -- if it finds ur name then it will print no duh if it doesnt find ur name it will print uh...oh...
        print ("no duh...")
    else
        print("uh...oh...")
    end
end
Ad

Answer this question