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

Are arguments already defined?

Asked by 7 years ago

So with functions, the name can be whatever you want it to be. But is that the same with arguments? For example, how does the script know that hit mean's hit. Since there is nothing to tell it what it is. Even if I change Hit to anything else it still works. My question is, are arguments already defined, if so where can I find a list of them. Thanks for clearing this up for me!

function touch(hit)             
    hit.Anchored = true             -- FIXES YOUR LEG IN PLACE >8D
end                             

script.Parent.Touched:connect(touch)
0
http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched --An example of the "Touched" arguments TheHospitalDev 1134 — 7y

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
7 years ago

An overview

When you connect a Signal to a function using :connect(), you are telling the signal to fire the function, whenever it is fired. It also passes arguments. If you change hit, you are just changing the name of the variable to use. The signal passes the object hit as the first argument, so the first variable defined in your function will be that.


Arguments

otherPart - The part which touches the object


Struggling?

My answer may of not helped you enough, but here is a link to the wiki if you are struggling.


Thanks for reading!

Thanks for reading my answer. If it helped, make sure to upvote it or set it as the correct answer!

0
Wow, thanks. So hit is just a variable. This really cleared things up for me! nonstoppoop639 22 — 7y
0
You're welcome. xAtom_ik 574 — 7y
Ad

Answer this question