There is an easiest way to do it.
var speed = 3 #---set your speed here
var a = state.get_transform().basis
set_linear_velocity(Vector3(a.x.z, a.y.z, -a.z.z) * speed)
#--This code will works to axis Z
#--To use another axis just multiply the Vectors you want to use
Vector3(a.x.z, a.y.z, -a.z.z) * Vector3(a.x.x, a.y.x, -a.z.x)
var speed = 3
var a = state.get_transform().basis
var z = Vector3(a.x.z, a.y.z, -a.z.z)
var y = Vector3(a.x.y, a.y.y, -a.z.y)
set_linear_velocity((y * z) * speed)
#---Just be aware...any number Multiplied by zero is = zero, so check if the angle of your ship is not equal to zero. in this case turn your 0 to 1 or your ship won't move.
#-- angular velocity works almost the same way.
var speedspin = 2
var a = state.gettransform().basis.x
setangularvelocity(Vector3(a.x, a.y, a.z) * speed_spin)