You are using the correct WebUI method, getAttribute() but I suspect you are not identifying the element successfully or perhaps not identifying the value attribute correctly.
Your code should look something like this
// Get the VALUE attribute of the test object
String val = WebUI.getAttribute(findTestObject("path-to-test-object"), "value")
println "Value is: " + val
In future, when posting an issue like this, make sure you post all relevant information. Please follow this advice: