I’m attempting to get a transform from a raycasthit but it says

Assets/scripts/Weapon script.js(28,38): BCE0020: An instance of type ‘UnityEngine.RaycastHit’ is required to access non static member ‘transform’.

i have a ray setup but don’t know what all is needed.

var Hittarget:Transform = RaycastHit.transform;

You need an RaycastHit instance.

Init a variable for the result:

var hit:RaycastHit;

Then you need to fill your hit variable with the hit data, by using a Physics function e.g:

if (Physics.Raycast(ray, hit, Mathf.Infinity, mask)) {
// hit can now be accessed like in your example
var Hittarget:Transform = hit.transform;