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

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

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

4 comments

0

You're comparing the player object to the the string. Just replace it with plr:GetPlayers()[1].Name == nombre.

0

This worked! Thank you so much!

0

I'm assuming that "plr" is a variable representing the "Players" service.

0

Also, np.

1 answer

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

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