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

how to check if a instance has a certain property?

So I was doing a i,v loop on workspace

heres what the code looks like

for i,v in pairs(workspace:GetChildren()) do
	if v.Disabled then
		v.Disabled = true
	end
end


But it saids v.Disabled is not a valid member

and there is no findfirstchild for a property too

3 comments

0

You can check the classname first.

0

BUT IT HAS TO BE A FOR IV LOOP

0

start accepting answers -._-.

1 answer

Varies, In this case I used a pcall.

If it is errored, it is contained by the pcall and will not break the script. Otherwise v.Disabled will equal true

pcall(function()
	v.Disabled=true;
end);

3 comments

0

isnt this expensive?

0

well you could alternatively check the classname,

0

@ScriptingHelpersSucs no this would affect performance by a noticeable amount. No worries. But accept the answer now.

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