model = game.Workspace.TARDIS:GetChildren() for i, v in pairs(model) do for i = 0, 0.01, 1 do -- I think this is the problem? i.Transparency = 1 end end
Hmm, there is a few problems with your code; Line 4: i
is being used twice, and can mess up your script when running. Line 5: i.Transparency = 1
? You are attempting to use index i
as an identifier for the Child
, when it is supposed to be an identifier for a Number Value/Identifier. Let me explain;
model = game.Workspace.TARDIS:GetChildren() --Why is this necessary? And what is 'TARDIS' is not existant at the time of execution? for i, v in pairs(model) do --Correct for i = 0, 0.01, 1 do --Correct, this is where one of the problems lye. i.Transparency = 1 --Identifier 'i' is being used to identify the current Child being looped through? end end
As I have pointed out, there are three problems in your code, however, this can be fixed by using the WaitForChild method, fixing up the for loop, and fixing the identifier for the for
loop, now, let's fix up your code;
local model = game.Workspace:WaitForChild("TARDIS") --Identifier 'model' is specifying the Child 'TARDIS' when it is existant; This will repeat waiting until Child 'TARDIS' is existant within 'game.Workspace', and will identify it when existant for i,v in pairs(model:GetChildren()) do --Why not put 'GetChildren' right here? You may use identifier 'model' for another purpose in another code; The 'GetChildren' method creates a table of the current Children within the Parent [Parent:GetChildren()] if v and v:IsA("BasePart") then --Another thing I forgot to mention earlier; What if the object is not a 'BasePart' type instance, or if the 'BasePart' type instance is not existant? coroutine.wrap(function() --EDIT: The 'coroutine.wrap' function will all the thread of code to run without pausing the code for x = 0, 1, 0.01 do --Now, 'x' is now identifying the 'Number' that is currently being used; v.Transparency = x --'v' is the identifier for the Child; Changes the 'BasePart' type instances 'Transparency' to identifier 'x''s Number until it is equal to one wait(.1) --Why not add a 'wait' to make the effect more real? Without the 'wait', it would automatically become Transparent end --Ends the code block for the 'for' loop end)() --Ends the code block for the 'coroutine' end --Ends the code block for the 'if' statement end --Ends the code block for the 'for' loop
Hope this helped, and sorry if I did not give a good explanation!