I've created a cloud script function that takes an argument called "InAttributeName" so that I may dynamically update an attribute of my choosing from code in Unreal. For some odd reason when I call this script it runs with no exceptions but somehow the attribute that I pass through is not incremented. Instead a new attribute is added to my player data and that one is incremented. What really blows my mind is that this new attribute that is added is the same name as my var "InAttributeName". How is this even possible and how do I fix it?
handlers.IncrementPlayerAttribute = function (args, context) { // Get the current value of the attribute we are trying to increment var InAttributeName = args.AttributeName; var playerData = server.GetUserReadOnlyData({ PlayFabId: currentPlayerId, Keys: [InAttributeName] }); log.info(playerData); prevCount = playerData.Data[InAttributeName].Value; var prevInt = parseInt(prevCount, 10); var nextCount = (prevInt + 1).toString(); // Update the user data var value = server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Data: { InAttributeName: nextCount } }); // TESTING ONLY playerData = server.GetUserReadOnlyData({ PlayFabId: currentPlayerId, Keys: [InAttributeName] }); log.info(playerData.Data[InAttributeName]) };