generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

function(property, property2, property3)

Previous Thread :: Next Thread 
Miro034 is not online. Miro034
Joined: 07 Oct 2009
Total Posts: 6568
09 May 2012 11:52 AM
This is really basic and I am unable to use it. I just need to enchance my skills by finding how smart these properties and how can they be used. Please give me some examples.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
09 May 2012 11:57 AM
function asd(blah,blah2,blah3)
print("blah = ".. blah)
print("blah2 = ".. blah2)
print("blah3 = ".. blah3)
end

asd("Hello","world","!")

>blah = Hello
>blah2 = world
>blah3 = !
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
09 May 2012 12:26 PM

Here is a function you will probably recognise:

function findNearestTorso(pos) --- WE CAME HERE FROM LINE 100, WAY BELOW... Notice, nowhere is the variable, pos, declared. Thats because it is declared right here. It will be "local" to this function only, and will cease to exist when this function is finnished. But what is the value of, pos, right now? Goto line 100

local list = game.Workspace:children()
local torso = nil --- TORSO - the center point of the nearest-guy - doesn't exist.

local dist = 1000
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do --- 'everybody' (Everything, actually)
temp2 = list[x] ---- first 'everybody'

if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso") --- Is the first 'everybody' a Model, AND not me, and has a TORSO?

human = temp2:findFirstChild("Humanoid") --- Does it have humaness?
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then --- If it has a torso and humaness...AND

if (temp.Position - pos).magnitude < dist then --- AND is within 1000 (studs?)
torso = temp ----- TORSO - A CENTERPOINT (POSITION)- is going to be this guy, 'TEMP', nearest to us.
dist = (temp.Position - pos).magnitude ---- HE IS this FAR AWAY FROM "pos", the entity which called this routine. (BTW. Why do we need to know this?)
end
end
end
end
return torso ---- go Back where you came from with this guy's TORSO's handel, as the value returned
end ----- else TORSO still does not exist. Everybody must be dead. Return with Torso as nil.



while true do
wait(0.1) --- THIS SHOULD NOT BE (.1) *

100 local target = findNearestTorso(script.Parent.Torso.Position) -- Go do FindNearest(), then stuff TARGET with the 'Position' of TORSO, the centerpiece of some unlucky guy near us, which was returned.

-- HERE, WE CALL FINDNEARESTTORSO. wE PASS A VALUE TO THAT FUNCTION ALSO, script.Parent.Torso.Position, A VECTOR3 VALUE, WHICH IS A LIST OF 3 NUMBERS: oUR POSITION IN THE WORLD, X,Y, & Z. sO POS NOW HAS THE VALUE OF script.Parent.Torso.Position; MAYBE, 5,0,5.

-- tHE "TARGET =" PART RETRIEVES A VALUE FROM FINDNEAREST, A POINTER TO THE TORSO THAT WE JUST FOUND.

if target ~= nil then ---- Remember TORSO started as nil; else we have a live-one.
script.Parent.Zombie:MoveTo(target.Position, target) ---MOVE TOWARDS TORSO (now called TARGET).
end
end

gL,
bRIAN
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image