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

Script that loops and changes the transparency of an object one by one?

Asked by 4 years ago
Edited 4 years ago

ok so like i have this script right and it plays the decals and makes it a video then it looks pretty good but its really really time consuming ~~~~~~~~~~~~~~~~~ function onClicked() script.Parent.Parent.one.Transparency=0 wait(0.16) script.Parent.Parent.one.Transparency=1 script.Parent.Parent.two.Transparency=0 wait(0.16) script.Parent.Parent.two.Transparency=1 script.Parent.Parent.three.Transparency=0 wait(0.16) script.Parent.Parent.three.Transparency=1 script.Parent.Parent.four.Transparency=0 wait(0.16) script.Parent.Parent.four.Transparency=1 script.Parent.Parent.five.Transparency=0 wait(0.16) script.Parent.Parent.five.Transparency=1 script.Parent.Parent.six.Transparency=0 wait(0.16) script.Parent.Parent.six.Transparency=1 script.Parent.Parent.seven.Transparency=0 wait(0.16) script.Parent.Parent.seven.Transparency=1 script.Parent.Parent.eight.Transparency=0 wait(0.16) script.Parent.Parent.eight.Transparency=1 script.Parent.Parent.nine.Transparency=0 wait(0.16) script.Parent.Parent.nine.Transparency=1 script.Parent.Parent.ten.Transparency=0 wait(0.16) script.Parent.Parent.ten.Transparency=1 script.Parent.Parent.eleven.Transparency=0 wait(0.16) script.Parent.Parent.eleven.Transparency=1 script.Parent.Parent.twelve.Transparency=0 wait(0.16) script.Parent.Parent.twelve.Transparency=1 script.Parent.Parent.thirteen.Transparency=0 wait(0.16) script.Parent.Parent.thirteen.Transparency=1 script.Parent.Parent.fourteen.Transparency=0 wait(0.16) script.Parent.Parent.fourteen.Transparency=1 script.Parent.Parent.fifteen.Transparency=0 wait(0.16) script.Parent.Parent.fifteen.Transparency=1 script.Parent.Parent.sixteen.Transparency=0 wait(0.16) script.Parent.Parent.sixteen.Transparency=1 script.Parent.Parent.seventeen.Transparency=0 wait(0.16) script.Parent.Parent.seventeen.Transparency=1 script.Parent.Parent.eighteen.Transparency=0 wait(0.16) script.Parent.Parent.eighteen.Transparency=1 script.Parent.Parent.nineteen.Transparency=0 wait(0.16) script.Parent.Parent.nineteen.Transparency=1 script.Parent.Parent.twenty.Transparency=0 wait(0.16) script.Parent.Parent.twenty.Transparency=1 script.Parent.Parent.twentyone.Transparency=0 wait(0.16) script.Parent.Parent.twentyone.Transparency=1 script.Parent.Parent.twentytwo.Transparency=0 wait(0.16) script.Parent.Parent.twentytwo.Transparency=1 script.Parent.Parent.twentythree.Transparency=0 wait(0.16) script.Parent.Parent.twentythree.Transparency=1 script.Parent.Parent.twentyfour.Transparency=0 wait(0.16) script.Parent.Parent.twentyfour.Transparency=1 script.Parent.Parent.twentyfive.Transparency=0 wait(0.16) script.Parent.Parent.twentyfive.Transparency=1 script.Parent.Parent.twentysix.Transparency=0 wait(0.16) script.Parent.Parent.twentysix.Transparency=1 script.Parent.Parent.twentyseven.Transparency=0 wait(0.16) script.Parent.Parent.twentyseven.Transparency=1 script.Parent.Parent.twentyeight.Transparency=0 wait(0.16) script.Parent.Parent.twentyeight.Transparency=1 script.Parent.Parent.twentynine.Transparency=0 wait(0.16) script.Parent.Parent.twentynine.Transparency=1 script.Parent.Parent.thirty.Transparency=0 wait(0.16) script.Parent.Parent.thirty.Transparency=1 script.Parent.Parent.thirtyone.Transparency=0 wait(0.16) script.Parent.Parent.thirtyone.Transparency=1 script.Parent.Parent.thirtytwo.Transparency=0 wait(0.16) script.Parent.Parent.thirtytwo.Transparency=1 script.Parent.Parent.thirtythree.Transparency=0 wait(0.16) script.Parent.Parent.thirtythree.Transparency=1 script.Parent.Parent.thirtyfour.Transparency=0 wait(0.16) script.Parent.Parent.thirtyfour.Transparency=1 script.Parent.Parent.thirtyfive.Transparency=0 wait(0.16) script.Parent.Parent.thirtyfive.Transparency=1 script.Parent.Parent.thirtysix.Transparency=0 wait(0.16) script.Parent.Parent.thirtysix.Transparency=1 script.Parent.Parent.thirtyseven.Transparency=0 wait(0.16) script.Parent.Parent.thirtyseven.Transparency=1 script.Parent.Parent.thirtyeight.Transparency=0 wait(0.16) script.Parent.Parent.thirtyeight.Transparency=1 script.Parent.Parent.thirtynine.Transparency=0 wait(0.16) script.Parent.Parent.thirtynine.Transparency=1 script.Parent.Parent.forty.Transparency=0 wait(0.16) script.Parent.Parent.forty.Transparency=1 script.Parent.Parent.fortyone.Transparency=0 wait(0.16) script.Parent.Parent.fortyone.Transparency=1 script.Parent.Parent.fortytwo.Transparency=0 wait(0.16) script.Parent.Parent.fortytwo.Transparency=1 end script.Parent.ClickDetector.MouseClick:connect(onClicked) ~~~~~~~~~~~~~~~~~

so like yeah i was wondering if there was a way for only a few lines of code to go through every decal in the brick and change the transparancy from 0 to one and wait in between and loop for every decal then end once there is no more decals to scan and do

0
yikes, mind if you use a loop? heres a link: 123nabilben123 499 — 4y

1 answer

Log in to vote
0
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

Here's all I can think of by your explanation

-- >> New code
local decals = script.Parent.Parent:GetChildren()

script.Parent.ClickDetector.MouseClick:Connect(function()
    for i = 1, #decals do
        script.Parent.Parent[i].Transparency = 1
        wait(0.16)
    end
end)

-- >> Old Code
--[[
script.Parent.ClickDetector.MouseClick:Connect(function()
    for _,v in pairs(workspace.Brick:GetChildren()) do -- loops through the brick
        if v:IsA("Decal") then -- ensures its a decal
            v.Transparency = 1 -- changes the transparency
            wait(0.16) -- waits the set time
        end
    end
end)
]]
0
no i mean like so say there is 42 decals in a brick they are all transparent i want it to take the first one make it visible then make it invisible and then go to the next until their is no more decals so then it looks like it played a video supersoli12345 6 — 4y
0
Then have them numbered, dont name them out, if you could do that and update it, I could help you out 0_2k 496 — 4y
0
Updated 0_2k 496 — 4y
0
le epic thanks supersoli12345 6 — 4y
0
Mind marking as solution then? 0_2k 496 — 4y
Ad

Answer this question