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

"attempt to concatenate userdata with string", but what I defined is a string?

I have two variables,

local team1 = nil
local team2 = nil

I define them when a part is clicked as:

team1 = clicked.Name

team2 = clicked.Name

(Clicked being the player who clicked the part obviously)

I later try to use them when I send a remote event to the client.

T1Betray:FireAllClients(player, team1, team2)

and it is sent to this local script:

T1Betray.OnClientEvent:Connect(function(team1, team2)
		MainGui.TextLabel.Text = team1 ..  " Has Betrayed" .. team2
	end)

The error I receive is as shows; "attempt to concatenate userdata with string".

Can someone help me? I've defined the name of the player in the variable and it's supposed to work but I've been unable to find any solution and I'm pretty sure all prior script is correct, thanks in advance!

1 answer

✓ Accepted answer

When you are firing T1Betray to ALL Clients, you do not need to provide a Player argument. You are setting the first argument to a Player instance and then trying to concatenate it with other strings. This can most likely be fixed by simply removing argument 1 ofT1Betray:FireAllClients

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