Attempt to concatenate string with instance

Greetings,

I am getting an error (Attempt to concatenate string with instance) on Line 27 which I marked below.

	local TruePlayer1 = game.Players:WaitForChild(Player1.Value) --Player1 is a StringValue
	local TruePlayer2 = game.Players:WaitForChild(Player2.Value) --Player2 is a StringValue
	
	task.wait(2)
	
	print("Player 1: " ..TruePlayer1.. " | Player 2: " ..TruePlayer2) --Line 27

Thanks.

1 Like

TruePlayer1 and TruePlayer2 are both instances, so you can’t concatenate them. What I assume you want is:

	local TruePlayer1 = game.Players:WaitForChild(Player1.Value) --Player1 is a StringValue
	local TruePlayer2 = game.Players:WaitForChild(Player2.Value) --Player2 is a StringValue
	
	task.wait(2)
	
	print("Player 1: " ..TruePlayer1.Name.. " | Player 2: " ..TruePlayer2.Name) 
2 Likes

You have to put the .value after WaitForChild.

1 Like

Thank you so much! Works very nicely now.

1 Like