I am trying to make a script that will cycle through models and turn them into a certain material depending on what color it is. Right now I only have the script that will cycle through it, but it won't work. The error it gives me is " Argument 1 missing or nil." It is in a server script. This is the code:
local S = game.Workspace local T = game.ServerStorage function cycle() local P = S:FindFirstChild() if P:IsA("Model") then repeat Parts() until P:FindFirstChild() == nil end end function Parts() local C = P:FindFirstChild() if C:IsA("Part")then elseif C == nil then P.Parent = T.Analyzed repeat re() until T.Analyzing:FindFirstChild() == nil else C.Parent = T.Analyzing end end function re() local R = T.Analyzing:FindFirstChild() if R ~= nil then R.Parent = P end end function B() local M = T.Analyzed:FindFirstChild() if M ~= nil then M.Parent = S end end repeat cycle() wait(1) until S:FindFirstChild() == nil repeat B() wait(1) until T.Analyzed:FindFirstChild() == nil
Edit: I know it won't change the material yet since I have not coded it in yet. I am just trying to see if it will move the materials to the holding folder.
The reason this script errored is because you forgot to place the arguments in for all of the "FindFirstChild()" functions. Placing those arguments in should fix the script.
Example Code:
function Scan(Object) for i,v in pairs(Object:GetChildren())do wait() --[[Place a wait here or else your game/studio will lag or crash depending on the amount of objects that were in you first scan.]] if v:IsA("Part") then --Change color, texture, etc here. Scan(v) else Scan(v) end end end Scan(game.Workspace) --This script will scan though the object that you place in arg1 of the function "Scan".
Is this what you are looking for?