Ad
Log in to vote
0

Changing the transparency of several parts?

Asked by 8 days ago

I have been trying to make a script the causes a wall of parts to flicker (Like a forcefield), however: A. They are all the same name B. There are more then 20 parts C. It would create thousands of lines of code. Can you guys help me out? Is there some sort of function I can use?

local UIS = game:GetService("UserInputService")
local rp = game.ReplicatedStorage

UIS.InputBegan:Connect(function(Input,IsTyping)
    if IsTyping then
        return

    elseif
        Input.KeyCode == Enum.KeyCode.Q then
        rp.SpecialMoves.ATField:FireServer()
        local fieldSound = game.Workspace["AT SOUND"]
        fieldSound:Play()
        wait(1)
        local ATFIELD = game.Workspace.ATObject:GetChildren()
        ATFIELD.Transparency = 1
    end 
end)

1 answer

Log in to vote
1
Answered by 8 days ago

You almost got it. You just needed a for loop to go through ATObject's children.

local ATFIELD = game.Workspace.ATObject:GetChildren()
for index,child in pairs(ATFIELD) do
    child.Transparency = 1
end
Ad

Answer this question