How to check if Roblox functions use arguments?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

So like I want to know if a Roblox function example:

pcall(function()

end)

Actually uses function arguments example

  1. What is the issue?

I want to know this without having to manually check everytime like is there an api on this topic

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

searched it up on google. Non-conclusive answers

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

pcall(function() --Does it have an argument it can use or not?"
	print("Hello World!")
end)

game:GetService("UserInputService").InputBegan:Connect(function() -- How many arugemts can it or will it take???
	
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

arguments like “function(arg, arg2, arg3, etc)”

To avoid a potential xy problem, could you explain what you actually want to do.

go to Lua Globals | Documentation - Roblox Creator Hub
and scroll down to pcall(), you will see what you need to pass and what it returns.

I think the answer you are looking for is… check the roblox dev hub.

So if i use a roblox function built in one. I want to know if it has argument or not like

game:GetService("UserInputService").InputBegan:Connect(function(How many arguments does it take?)

“I want to know this without having to manually check everytime like is there an api on this topic”

You can use varargs (…) to see how many arguments it has been passed.

function(...)
    print(select('#', ...)) --> The number of arguments passed in that function
end
2 Likes

:Connect() is a method of InputBegan, you are passing function().
if you go to UserInputService | Documentation - Roblox Creator Hub
you will see you need to put input and gameProcessedEvent (UserInputService | Documentation - Roblox Creator Hub)

not those types of arguments like “function(arg, arg2, arg3, etc)”
and not in added function roblox function like :Connect()

Depending on your case it can be possible to check for arguments rather than if functions do use arguments or not, since some methods on Roblox change behaviours depending on what is (or isn’t) passed.

The best way to check if a function uses arguments and what it passes is to look at documentation via the Developer Hub or the resource you are using. You should never have to do this from a script because arguments passed should be predictable; if they aren’t, you have a different problem to solve which is that unpredictability in your code.

If you really have to know, use the variadic operator. Only works in some cases though.

local function foobar(...)
    print(...) -- Print concatenates its arguments
end

foobar("arg1", "arg2")

Yes that but in roblox functions? ones that come defeault like :Connect() if you know what I mean

Any form of connect takes a function only.

You can find almost everything else you need from the Developer Hub. Always read the docs. Takes less time than trying to find it out with code and spending more time asking questions or writing threads for things you can look up.

What are you looking for then? Varargs are accepted in “Roblox” functions. Why do you think it would different between “Roblox” functions and other functions?