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

Do Events provide built-in arguments?

Asked by
emite1000 335 Moderation Voter
10 years ago

I have done some testing, and after findings such as this and example 2, I have pretty much come to the conclusion that many Events have built-in values that they can give to arguments.

However, I was not able to find anything on the Wiki about this. Can anyone confirm this claim for me, and possibly add any additional information they know about it (such as which Events have arguments to give)

Example 2: In a script inside a Part, write:

1function Frap(Goo)
2    Goo.BrickColor = BrickColor.new("Camo")
3end
4script.Parent.Touched:connect (Frap)

When the player touches the Part, whatever touched it will turn to the color Camo. Even though Goo was never actually defined when the function was called, Touched gave a value to it.

0
Yes. Many events have built in parameters. Perci1 4988 — 10y
0
If you look at the wiki page for the event it does show what parameters it has. NotsoPenguin 705 — 10y
0
Most of these things we don't think about. We just take them for granted because they just work. Tkdriverx 514 — 10y
0
No, not everything has it's own parameter. For example Mouse1Click doesn't have a parameter for the player. EzraNehemiah_TF2 3552 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

It's kinda like this code:

1function PrintMe(messagetoprint)
2    print(messagetoprint)
3end
4 
5PrintMe("This is a test")--It will print "This is a test". connect basicly just does this whole argument thing by itself. Like a little mini-script helper that just comes and gives you the arguments without you needing to find them yourself.

I think that events do have their own arguments because of the :connect() part. Compair Script1 to 2. (I know script 2 is wrong. It's just to give an idea.) Script 1

1script.Parent.Touched:connect(function(hit) --So easy. 3 lines.
2    hit.BrickColor = BrickColor.new(0) --Black
3end

Script 2

01hitparts = {} --21 lines. ermgosh.
02local count = 0
03 
04while wait() do
05    for _,parts in pairs(workspace:GetChildren()) do
06        if parts:IsA("Basepart") and math.abs(parts.Position.X)-math.abs(script.Parent.Position.X) == 1 or math.abs(parts.Position.Y)-math.abs(script.Parent.Position.Y) == 1 or math.abs(parts.Position.Z)-math.abs(script.Parent.Position.Z) == 1 then
07            count = count+1
08            hitparts[count] = parts
09        end
10    end
11end
12 
13function onTouch(hit)
14    hit.BrickColor = BrickColor.new(0) --Turn the part to black
15end
View all 21 lines...


The connect is a RBXScriptSignal. When you use the connect, if you're doing a touched script, it would make a RBXScriptConnection object. This object returns the part you touched in this case.


Yes, events do have their own arguments thanks to RBXScriptConnection!

0
Does every Event have its own argument? Even ones like ChildAdded? emite1000 335 — 10y
Ad

Answer this question