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

Changing the transparency of several parts?

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

✓ Accepted answer

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

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