Patched up your script and added several comments either starting with 'EDIT' or 'NOTE'.
-- EDIT: Removed imported scripts and declaration of l_0_0, there is no need to import those scripts and l_0_0 is never used
MissionSetup = function() -- basic mission setup function which is used in almost all bully scripts
-- EDIT: Renamed variables to 'X', 'Y', and 'Z' as these are more descriptive names
local X = 270 -- X coords
local Y = -110 -- Y coords
-- NOTE: There is no need to make your coordinates this specific, but there is nothing wrong with it either. I suggest only using 1 or 2 decimal places for simplicity.
local Z = 6.4000000953674 -- Z coords
-- EDIT: Made 'Nil' lowercase, LUA is a case sensitive language and nil should be 'nil'.
local Algernon = nil -- Initialize bullied char
-- EDIT: Made 'Damon' a local variable.
Damon = nil -- Initialize bully
DisablePunishmentSystem(true) -- Necessary to keep the prefects from interfering
PlayerSetHealth(200) -- gives the player 200 health
AreaTransitionXYZ(0, X, Y, Z) -- Moves player to outside boys' dorm
TextPrintString("Algernon is one of the geeks at school. He needs protection from Damon, the jock who has been bullying him.", 4, 1) -- Posts red text on screen
Algernon = PedCreateXYZ(4,265,-110,6.4000000953674) -- Spawn bully target
Damon = PedCreateXYZ(12,262,-110,6.4000000953674) -- Spawn bully
-- EDIT: 'gplayer' to 'gPlayer'.
PedRecruitAlly(Algernon,gPlayer) -- Second character assigned to bodyguard first
-- EDIT: Lowered Damon's attitude towards the player faction (13) if it was high so that Damon will be able to fight you if you intervene.
if PedGetPedToTypeAttitude(Damon,13) > 2 then
PedSetPedToTypeAttitude(Damon,13,2)
end
PedAttack(Damon, Algernon, 1) -- Bully attacks target
-- NOTE: The function 'PedGetName(ped)' can also be used to get the ped's name, but it is ultimatly up to you.
PedShowHealthBar(Algernon, true, "N_Algernon", true) -- Display Algernon's health bar
end
MissionCleanup = function()
end -- end statement
-- EDIT: Removed F_MissionCheck as the code fits better in the main function
main = function() -- Main mission function
repeat
-- EDIT: Adjusted the call to 'Wait' so that the script only gets suspended for 1 frame (0 milliseconds) each time the repeat loop runs.
Wait(0)
until PedIsDead(Damon) -- NOTE: This means the repeat loop will keep running until 'PedIsDead' returns true (when Damon is KO'd)
-- EDIT: Added time and style. 'TextPrintString' takes 3 arguments: textString, time (seconds), and style (1 for top of the screen and 2 for the bottom)
TextPrintString("Congratulations! Algernon is safe for now thanks to your intervention.",2,1)
-- NOTE: Added a call to 'Wait' so the script is suspended for 2000 milliseconds (2 seconds) to give the script time to print the text before the script is terminated
Wait(2000)
-- EDIT: Added call to 'MissionSucceed'
MissionSucceed()
end
-- EDIT: Fixed the indendting through-out the whole script.
Notice that I say gplayer was wrong and that you should use gPlayer. You may be wondering "but it worked fine with gplayer, so why is it wrong?" and there is a reason for that. In your original script, gplayer was never created, so when you used it, it's value was nil, meaning it didn't have a value. In many of Bully's functions that expect a number as an argument, nil gets defaulted to 0, which just so happens to be the player's ped. So really both ways work, but gPlayer is the right way to do it, since gPlayer is a global variable (global to all scripts) referring to the player. Oh and if it confused you that the player is 0, peds in LUA are simply numbers referring to them, it's called a ped handle. If you want me to explain more about this I can but I won't ramble about it too long now.
Welcome to the board by the way, enjoy your stay. It's nice to see some more interest in modding these days.