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

how to excute multiple parts at the same time ?

Asked by
uuuud 0
2 years ago

local ye = true function disapper (part) part.CanCollide = false part.Transparency = 1 end function apper (part) part.CanCollide = true part.Transparency = 0 end function excute (yes, parts) if yes then while true do disapper(parts) wait(4) apper(parts) wait(4) end else while true do apper(parts) wait(4) disapper(parts) wait(4) end end end local a = game.Workspace:GetChildren() for i,v in pairs(a) do if string.match(v.Name,'dis') then if i % 2 == 0 then excute(ye,v) else end end end

so lets say there are 8 parts that called disappering platform i want every even ones to disapper at the same time then the other 4 disapper at the same time but in this scrpit it only excute 1 at a time so first one goes after 8 sec the other goes i want all the first 4 to go toghter at the same time plz help

1 answer

Log in to vote
0
Answered by
uuuud 0
2 years ago
local ye = true

function disapper(part)
    part.CanCollide = false
    part.Transparency = 1
end

function apper(part)
    part.CanCollide = true
    part.Transparency = 0
end


function excute(yes, parts)
    if yes then
        task.spawn(function()
            while true do
                disapper(parts)
                task.wait(4)
                apper(parts)
                task.wait(4)
            end
        end)
    else
        task.spawn(function()
            while true do
                apper(parts)
                task.wait(4)
                disapper(parts)
                task.wait(4)
            end
        end)
    end
end

local a = game.Workspace:GetChildren()


for i,v in pairs(a) do
    if string.match(v.Name,'dis') then
        if i % 2 == 0 then
            ye = true
            excute(ye,v)
        else
            ye = false
            excute(ye,v)
        end
    end
end


i got it nvm thx

Ad

Answer this question