CharacterRemoving page uses incorrect concatenation

The first code example on the CharacterRemoving documentation page shows something being concatenated but it’s using incorrect concatenation for Lua.

print(player.Name + " spawned!")

Will error because it using a “+” instead of “..”; this line should be

print(player.Name .. " spawned!")

9 Likes

Web devs forgot this ain’t js

Still would be cool if we had the plus operator for string concatenation

1 Like

EDIT: nevermind you can do this with regular lua but not rbxlua

getmetatable("").__add = function(a,b)
	return a..b
end

-> print("a" + "b")
<- ab

 -- can do it with other operators as well!
getmetatable("").__mod = function(a,b)
	return a..b
end

-> print("a" % "b")
<- ab
2 Likes