To answer your question, parameters are the "variables" that you define in the parenthesis of a function.
local function boop(one, hello)
end
Arguments are whatever values you pass to those parameters.
local function boop(one, hello)
print(one,hello)
end
boop("monkey","banana")
Roblox events pass arguments to any parameters of a connected function, For example, the Touched Event passes whatever touched the specified object as an argument to the first parameter of the given function.
local part = Instance.new("Part",workspace)
part.Touched:connect(function(hit)
print(hit)
end
The only reason you would ever need to use an anonymous event rather than convenience over connecting the function to an event would be to call that function without that event passing any arguments to the function
local part = Instance.new("Part",workspace)
local function boop(p)
print(p)
end
part.Touched:connect(function(hit)
boop("Hello")
end
One reason you might want to avoid anonymous events is because you'd have to redefine your function. By defining it and then linking it to an event, you can use that function elsewhere, too.
local part = Instance.new("Part",workspace)
local function boop(p)
print(p)
end
part.Touched:connect(function(hit)
boop("Hello")
end
for i = 1,5 do
boop(i)
end
1 comment
No, there is a differnce