Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!

Ad

Answer this question