Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

what does (hit) mean?

Asked by 8 years ago

i was in the wiki and it said this line of code

function(hit)

(Started learning scripting a week ago)

what does the (hit) mean i looked it up on the wiki. When they try to explain it the definition it doesn't make sense to me so can anyone tell what does the hit mean exactly?

1 answer

Log in to vote
4
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

The actual word 'hit' doesn't necessarily mean anything -- It's a parameter. It's not too different from a variable.

Some functions have built in parameters, and some don't. With non-built in ones, you can even make up your own and call them with an argument (basically a parameter, but it's used in the actual call to the function).

For example:

script.Parent.Touched(connect(function(hit) -- Hit could be anything. Part, object, bob, whatever. The touched function has a built-in parameter, being the object that touched the part.
    print(hit.Parent) -- You can use the parameter within the function, but not outside of it unless you set a variable to the value.
end)

As I previously mentioned, you could make your own functions with parameters:

function add(a, b)
    return a + b -- This would return the parameter a, added to the parameter b.
end

print(tostring(add(7,3))) -- I used the arguments 7 and 3, this would print 10.

Hope this helped!

0
Thank You i understand know bradleyawsome 10 — 8y
0
Unban me from chat pls NetworkMan243 65 — 8y
0
Once again, please submit a ticket to helpdesk. Commenting on all of my answers will most likely just prolong your ban. Pyrondon 2089 — 8y
Ad

Answer this question