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

How can I change the transparency of a model with many parts using a tween?

I have a tween function created (See an example in line 4)

script.Parent.Parent.Bottom.Touched:Connect(function(hit)
    local humanoid = hit.parent:FindFirstChildWhichIsA("Humanoid")
     if humanoid ~= nil then
	  tween(2,"Linear","Out",{Position=Vector3.new(35.3, 5.388, -117.506)},script.Parent):Play()
          wait(3)
--   Here I want to put the tween
	    end
	end)

1 answer

✓ Accepted answer

You can loop through the models, then tween it for that. Example:

If they're all going to the same place, then try using this

local children = workspace:GetChildren()

for i,v in pairs(children) do
   tween(2,"Linear","Out",{Position=Vector3.new(0,0,0)},v):Play() 
end

But if they all have different places, then try something like this

local children = workspace:GetChildren()

for i,v in pairs(children) do
   if v.Name == "Part1" then
       tween(
           2,
           "Linear",
           "Out",
           {Position=Vector3.new(0,0,0)},
           v
        ):Play()
    elseif v.Name == "Part2" then
        tween(
            2,
            "Linear",
            "Out",
            {Position=Vector3.new(0,1,0)},
            v
        ):Play()
    end
end

But the second way isn't the best way, I just did that as an example. I recommend having a table storing each part's position and looping through that table and set the part's position to its thingy

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