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

. and : before functions?

What is the difference or why do we put . before some functions and : before other functions?

1 comment

0

I pretty sure ":" is a method called on an object, and "." is indexing part of a dictionary (e.g math)

1 answer

✓ Accepted answer

I recently gave an answer to a very similar question.

If you're indeed referring to the dot and comma syntax when calling the default Roblox API functions, the behaviour is still the exact same. The API and its documentation uses the dot syntax for class constructors (such as CFrame.new) and colon syntax for other member functions. This doesn't mean that either cannot be called with the other syntax (although none of the constructors accept a blank class as an argument, so the comma syntax can't really be used with constructors).

For example, game.FindFirstChild(workspace, "Baseplate") is totally valid syntax. It calls the Instance.FindFirstChild function with the Workspace service as the first argument and a string Baseplate as the second argument. The function call is attempting to find a child named Baseplate from the Workspace service.

7 comments

0

Not what he is looking for

0

I'd argue that's exactly what he is looking for; what each syntax does. The difference between the two can quite clearly be seen from the answer.

0

he's talking about things like CFrame.Angles() and FindFirstChild()

0

I updated the answer. They're still used like any other 'custom' member function and the difference is the exact same.

0

I'm not sure if this is correct? I would read here http://lua-users.org/wiki/ColonForMethodCall 

0

@Vulkarin That doesn't conflict with my answer(s) at all.

0

The : syntax is merely sugar in that :FindFirstChild case

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