how to get first name from DisplayName?


I have this code:

// @ input Component.Text UserNameText;

global.userContextSystem.requestDisplayName(function(displayName) {
var FullName = displayName.split(' ');
var FirstName = FullName[0];
//var LastName = FullName[FullName.length - 1]; < if you want the last name
script.UserNameText.text = FirstName;

I dont really understand how to "expose" the text component as stated on scripting overview in the docs.
i have put the script as a component of the text object but it doesnt work, i have also tried to have the script as a child of the the text object.


Best Answer