I’m creating a system that makes the model’s transparency and collision alter every two seconds for example, by changing the transparency and CanCollide setting of the model’s children. It works using just the independent parts, but using the models children, it doesn’t work. What’s wrong with the code?
GetChildren returns a table of objects that are a child of the instance the function was used on, you need to loop through the table using pairs or ipairs and change the transparency form there
Something like this is what you want
local map = game.Workspace.Model:GetChildren()
local function waitAndChange(transparency)
wait(2)
for _, part in ipairs(map) do
if not part:IsA("BasePart") then --Incase you got non parts in the map model
continue
end
part.Transparency = transparency
end
end
while true do
waitAndChange(1)
waitAndChange(0)
end
Make sure that the Model that is in line 1 is the only 1 model thats named Model in workspace or your script will get confused because it won’t know which Model your wanting to do something to it.(if theres 2 of them named Model.)