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

Make a part transparent if 2 objects are located in a model?

I want to make one part transparent when 2 objects are located in a model... What is wrong with this script? help please

while wait(5) do
local found = script.Parent.Parent.Parent.PurchasedObjects:FindFirstChild("mine1","mine2")
if found then 
  script.Parent.Parent.Parent.Badges.BadgeAwarderTH1.Platform.Transparency = 1
end
end

1 answer

Try using :GetChildren() if you want the script to see if there are 2 objects in the model.

:GetChildren() returns a table of instances, and adding a # in front of script.Parent.Parent.Parent.PurchasedObjects:GetChildren() will return the length of the tables. That is how many children there are in "PurchasedObjects" as a parent.

while wait(5) do
	if #script.Parent.Parent.Parent.PurchasedObjects:GetChildren() == 2 then -- Returns true if there are ACTUALLY 2 objects in the model.
  		script.Parent.Parent.Parent.Badges.BadgeAwarderTH1.Platform.Transparency = 1
	end
end

If you have any problems, please leave a comment below. Thank you and I hope this will help you!

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