1 | model = game.Workspace.TARDIS:GetChildren() |
2 |
3 | for i, v in pairs (model) do |
4 | for i = 0 , 0.01 , 1 do -- I think this is the problem? |
5 | i.Transparency = 1 |
6 | end |
7 | 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;
1 | model = game.Workspace.TARDIS:GetChildren() --Why is this necessary? And what is 'TARDIS' is not existant at the time of execution? |
2 |
3 | for i, v in pairs (model) do --Correct |
4 | for i = 0 , 0.01 , 1 do --Correct, this is where one of the problems lye. |
5 | i.Transparency = 1 --Identifier 'i' is being used to identify the current Child being looped through? |
6 | end |
7 | 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;
01 | 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 |
02 |
03 | 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()] |
04 | 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? |
05 | coroutine.wrap( function () --EDIT: The 'coroutine.wrap' function will all the thread of code to run without pausing the code |
06 | for x = 0 , 1 , 0.01 do --Now, 'x' is now identifying the 'Number' that is currently being used; |
07 | 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 |
08 | wait(. 1 ) --Why not add a 'wait' to make the effect more real? Without the 'wait', it would automatically become Transparent |
09 | end --Ends the code block for the 'for' loop |
10 | end )() --Ends the code block for the 'coroutine' |
11 | end --Ends the code block for the 'if' statement |
12 | end --Ends the code block for the 'for' loop |
Hope this helped, and sorry if I did not give a good explanation!