while wait() do
script.Parent.Head.Transparency = 1
wait(5)
script.Parent.Head.Transparency = 0
wait(5)
end
so this is what we had for the head, is there a way to make it affect the whole body, not just the head?
while wait() do
script.Parent.Head.Transparency = 1
wait(5)
script.Parent.Head.Transparency = 0
wait(5)
end
so this is what we had for the head, is there a way to make it affect the whole body, not just the head?
You can use an in pairs loop. a pairs loop is a loop where it loops through tables or arrays. You can use this to efficiently make the code shorter.
local NPCArray = script.Parent:GetChildren() --GetChildren() gets the children of the Parent.
while wait() do --This wait just make sures that the scirpt doesn't break.
for _, v in pairs(NPCArray) do --Loops through the table
if v:IsA("BasePart") then --IsA is self-explanatory. Is it a Part?
v.Transparency = 1 --Set transparency to 1
end
end
wait(5)
for _, v in pairs(NPCArray) do
if v:IsA("BasePart") then
v.Transparency = 0
end
end
wait(5)
end
Source: Alvinblox In Pairs Loop
This discussion is preserved as it was. New answers, comments, and votes are closed.