How can i make the parts inside a model go transparent at the same time - Traffic Light Scripting Help

How can i make it so that each 10 seconds the parts inside these models go transparent and come back (Example: Green (10 seconds) - Yellow (5 seconds) - Red (15 seconds) in a loop., after the countdown is done the parts inside need to go transparent, i tried unioning the parts inside but it just messed up their position in a weird way.

image
image

Use a for loop and maybe create a new thread in every loop.

Here is some template code:

local function makeModelTransparent(model, transparency)
    -- Loop over each child of the model
    for index, child in ipairs(model:GetChildren())
        -- If the child is a type of part, make it transparent
        if child:IsA("BasePart") then
            child.Transparency = transparency
        end
    end
end

Here is an example of this being used:

while true do
    makeModelTransparent(script.Parent.Bir.GreenBir, 0)
    makeModelTransparent(script.Parent.Bir.YellowBir, 1)
    makeModelTransparent(script.Parent.Bir.RedBir, 1)
    task.wait(10)
    makeModelTransparent(script.Parent.Bir.GreenBir, 1)
    makeModelTransparent(script.Parent.Bir.YellowBir, 0)
    makeModelTransparent(script.Parent.Bir.RedBir, 1)
    task.wait(5)
    makeModelTransparent(script.Parent.Bir.GreenBir, 1)
    makeModelTransparent(script.Parent.Bir.YellowBir, 1)
    makeModelTransparent(script.Parent.Bir.RedBir, 0)
    task.wait(15)
end

I would recommend trying out some AI tools (eg GPT, the built-in studio ones, etc) for things like this, they can often code basic things like this somewhat reliably.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.