Attempt to concatenate Instance with string - TextLabel

I want to make it so that the textlabel displays the player’s team and group rank but I keep getting this error:

Players.LMVM2041.PlayerGui.Cash.TextLabel.LocalScript:8: attempt to concatenate Instance with string

Code

repeat wait() until game.Players.LocalPlayer.Character
local grouprank = game.Players.LocalPlayer:GetRankInGroup(11187872)

local team = game.Players.LocalPlayer.Team
local text = script.Parent.Text

while wait(1) do
	text = "Current Team: "..team.." | Group Rank: "..grouprank
	
	team:GetPropertyChangedSignal("Team"):Connect(function()
		text = "Current Team: "..team.." | Group Rank: "..grouprank
	end)
end

Code is a local script inside of the textlabel. Can anybody help? I can’t identify the error.

team is an instance, change it to team.Name

1 Like

Hey, use team.Name instead of just team.

1 Like

3 things wrong with this

setting the text variable will not update the property, it will only change the variable, so you need to change local text = script.Parent.Text to be local text = script.Parent and when you need to change the property, do text.Text

team is a Team instance, so you’re mostly likely needing to do team.Name when concatenating

Your GetPropertyChangedSignal will error because Team instances don’t have a team property, I think you meant to use it on the localplayer

Also, something else, I dont think you need the repeat wait() until game.Players.LocalPlayer.Character line, you don’t use the localplayer’s character anywhere

2 Likes

I changed it to:

game.Players.LocalPlayer:GetPropertyChangedSignal("Team"):Connect(function()
	text.Text = "Current Team: "..team.Name.." | Group Rank: "..grouprank
end)

But it isn’t updating my team, when I change teams.

Because team references your old team, you need to update the team variable and then update the text

team = game:GetService("Players").LocalPlayer.Team before the text.Text line should do the trick

Also noticed this as well, you dont need the while wait(1) do loop, remove it

1 Like

Yeah, I noticed. I removed it earlier and it works perfectly.

1 Like