Welcome to my first tutorial post on this site
Okay let's start with some easy things;
_________________________________________________________________________
function hit(part)
print(part.className)
end
script.Parent.Touched:connect(hit)
Explaintion; The first line is naming a function to ´hit´ and naming the arguments ´part´ (in this touched Script the arguments will be the part that touched it).
The second line will print the part´s className (The part whoever touched it. to see what it print try this; View>Output)
The tirth line will end the function. Note; end´s are needed for an if statement, a function and do (such as for......do and while .... do)
The fourth line is epicley a must in this touched Script; when the script´s parent is hitted|touched then it will run the function name in the connect arguments so we named a function earlier to ´hit´ and when script.Parent is hitted|touched then it will run that function.
_________________________________________________________________________
Anoymous functions.
The Anoymous functions are pretty much the same ash normal functions, but there are changes;
script.Parent.Touched:connect(function(p)
print(p.className)
end)
This will work pretty much ash the normal functions, expect they don´t have a name, the connection is in the begin and the function end needs an ´)´. (only the function!)
_________________________________________________________________________
Calling functions
Calling functions is simple, for example;
function classname(p)
print(p.className)
end
classname(Workspace.myrco919.Head)
Now we name a function ´classname´ and the argument ´a´.
The second line it will print a´s className
The tirth line will end the function.
The fouth line; The suprising part is here, we called a function the ´classname´ (function name) my head wich will result into `Part´ since my head´s className is part.
Well this was my first guide, hope it helped.