Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

what does (hit) mean?

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

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!

3 comments

0

Thank You i understand know

0

Unban me from chat pls

0

Once again, please submit a ticket to helpdesk. Commenting on all of my answers will most likely just prolong your ban.

This discussion is preserved as it was. New answers, comments, and votes are closed.