Frame1 = script.parent["Frame 1"] Frame2 = script.parent["Frame 2"] for i = 1, math.huge do -- Frame1.Transparency = 1 Frame1.CanCollide = false wait(0.2) Frame1.Transparency = 0 Frame1.CanCollide = false Frame2.Transparency = 1 Frame2.CanCollide = false wait(0.2) Frame2.Transparency = 0 Frame2.CanCollide = true end
The script does work fine, but if I were to add on more frames then it would just get way bigger, and I'm pretty sure having more than one of this script might cause lag too.
Hi Birb,
local frames = script.Parent:WaitForChild("Frames Folder"):GetChildren(); local function change_props(obj, initial_props, end_props, t) -- obj is the frame and initial_props and end_props are dictionaries that have their indexes as property names and their values as the values for each property. Initial props are the first set of properties that the parts will become, and ending properties are the second set of properties that the parts will become. for name, prop in next, initial_props do -- for each iteration that has an index and a value obj[name] = prop; -- Gets the property and sets it to the value. end wait(t) for name, prop in next, end_props do -- for each iteration that has an index and a value obj[name] = prop; -- Gets the property and sets it to the value. end end for i = 1, #frames do -- Loops through all the frames local object = frames[i]; -- The frame local initialize_props = { -- What the properties will be first ["Transparency"] = 1; ["CanCollide"] = false; } local end_props = { ["Transparency"] = 0; -- What they will become after 0.2 seconds. ["CanCollide"] = true; } local t = 0.2; -- The time it waits before changing from initial properties to end properties. change_props(object, initialize_props, end_props, t); -- Calls on the function and passes the object and the initial and ending properties, as well as the time it waits before changing the initial and ending properties end
Thanks,
Best regards,
~~ KingLoneCat