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

I need help with lua Vocab. (what? and why?)

Okay, these are some of the words I need help with. (that are not mentioned in scripting glossary)

isA

for __ (mainly the '_' part)

ipairs

inpairs

...

ModuleScript


that's all I have on the top of my head at the moment =)

4 comments

1

If you search for these individually, you'll find answers to most/all of them already on the site.

2

isA has not been asked yet

2

why am I being devoted? I thought it was a pretty good question? Just because I don't know something doesn't mean I deserve to be devoted

1

Here I helped you out with your rep since it was uncalled for, for being devoted and you did ask a good question this site doesn't supply much detail on such topics..

1 answer

✓ Accepted answer

:IsA is a method of all instances (ROBLOX objects -- parts, scripts, models, services, etc).

It returns true if the object is the type of thing you ask for.

Usually, that will just be checking its ClassName (e.g., a Part has a "Part" .ClassName property).

Here's a simple example that checks if something can be assigned a random brick color using :IsA:

for _, object in pairs(workspace:GetChildren()) do
	if object:IsA("BasePart") then
		-- object will have a BrickColor, since it's a part-like-object
		object.BrickColor = BrickColor.random()
	end
end

ROBLOX organizes the types of objects into a hierarchy -- for instance, WedgeParts, Parts, SpawnLocations, etc, are all BaseParts. You can use :IsA("BasePart") to detect any type of part (where as :IsA("Part") or .ClassName == "Part" detect only Part objects themselves)

2 comments

1

so IsA just basically checks if the class name is BasePart and then executes the code

1

It doesn't ONLY work with "BasePart" as the argument. You can use IsA to check any type of Instance, for example IsA("Script") or IsA("ScreenGui"). IsA isn't too hard to understand, for it directly translates to English.

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