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

Need help getting this script to affect all parts in a model?

Asked by 8 years ago

Basically i need this script :

function myfunction()

script.Parent.Parent.Undercarriage.Transparency = 1 script.Parent.Parent.Undercarriage.CanCollide = false

end

script.Parent.ClickDetector.MouseClick:connect(myfunction)

To affect all the parts in the model called undercarriage, not just one which it is at the moment. Theres roughly 100 parts in this model called undercarriage so naming them all will be highly impractical and time consuming.

I'm a complete noob to scripting, don't judge me too harshly :D

1 answer

Log in to vote
1
Answered by 8 years ago

Sorry I can't explain any better.

function myfunction()  -- Function
    for i,v in pairs(script.Parent.Parent:GetChildren()) do -- Gather all the parts
        if v.Name == "Undercarriage" then -- If it's named a specific name
            v.Transparency = 1 -- Change the transparency
            v.CanCollide = false -- Make it CanCollide false
        end -- End the function
    end -- End the gathering
end -- End the if
-- Or I got the ending's in the wrong order e.e
script.Parent.ClickDetector.MouseClick:connect(myfunction) -- On click
0
Thanks, worked perfectly :D Riptide104 5 — 8y
0
No problem. ISellCows 2 — 8y
Ad

Answer this question