Welcome :)
For the sake of readability, please post script snippets in the code format as seen below. You can do this by selecting your pasted code and hitting the <>
code button. It will indent all the selected lines by 4 spaces. For it to properly work it needs to be proceeded by one empty line above it.
// the first part of the script is for automatic staging it should work during all the flight:
// automatic staging
when stage:liquidfuel < 0.1 then
{
stage.
preserve.
}
// the second part should be used to slowdown the vessel during the landing using the residual fuel left:
// this is to avoid the activation of the script during the first part of the flight
set trg to 0.
when alt:radar > 30000 then
{
set trg to 1.
print trg.
}.
// then during the landing it could be activated
until alt:radar < 30000
{
if trg = 1 {
SAS OFF.
lock heading to retrograde.
wait 10.
lock throttle to 1.}
}
// last part of the script is used to open the chutes automatically
// automatic chutes
until alt:radar < 2000
{
if trg = 1 {
chute on.}
}