Here's a new script that'll do what you're looking for with comments explaining it. (The lines starting with -- are comments and are ignored when the script runs).
-- Setup/cleanup:
function MissionSetup()
-- Set the player's position outside:
PlayerSetPosXYZArea(270,-110,6,0) -- args for this are similar to AreaTransitionXYZ, but it instead takes the area code (0 for outside) last.
-- Create Gary:
-- While it is entirely up to you how you name variables, we name this one starting with a "g" to indicate it is not a local variable (but is global instead).
gGary = PedCreateXYZ(130,271,-73,5.9)
-- Wait for the area to load before continuing (we switched to a new area using PlayerSetPosXYZArea).
while AreaIsLoading() do
Wait(0)
end
end
function MissionCleanup()
end
-- Main:
function main()
-- Get Gary's current position and store them in x, y, and z. These variables are also created as local variables, so they can't be used in another function.
local x,y,z = PedGetPosXYZ(gGary)
-- Wait for the player to be near Gary
while not PedIsInAreaXYZ(gPlayer,x,y,z,10) do -- call "PedIsInAreaXYZ", check if it returns false, and if so run the lines between "do" and "end"
Wait(0) -- suspend the script for one frame (0 ms) so other scripts can run and so the game can run (the game is completely frozen until your script waits)
x,y,z = PedGetPosXYZ(gGary) -- Update the value of x, y, and z incase Gary moved somehow.
end
-- Show "Success!" after the while loop above has completed, note that the while loop will continue to run until "PedIsInAreaXYZ" returns true.
TextPrintString("Success!",3,1) -- show the text for 3 seconds
Wait(3000) -- wait 3 seconds (3000 ms) for the text to go away
end
It's also important to know how the script will run. First, the script will be read from start to finish running any code it finds that isn't contained in a function. If it reads code that is in a function, that function will simply be put into memory so it can be called later. For Bully, it is sort of convention that you don't really call anything outside of any functions, but it's totally up to you how you want to do your scripts. You do at least need a few functions though, as after the script gets read from start to finish normally, Bully will call a few functions from your script. For mission scripts (such as ArcRace1.lur, what I assume you're using here), MissionSetup will be called first, then main after that finishes, and MissionCleanup when the mission ends.