Transparent And Collision

Hi I’m trying to make a script that makes a Model transparent and can Collide loop
Something like this
while true do
local part = game.Workspace.Part
part.Transparency = 1
part.CanCollide = false
wait(10)
part.Transparency = 0
part.CanCollide = true
wait(10)
but in that script i need to put it on every part so its messy and if i make it a model it will not work.

Now i need help to make a script

  1. loop
  2. transparency and can collide = off
  3. wait
  4. transparency and can collide = on
  5. on
    Untitled
1 Like

while true:
for each part in the model, set transparency and cancollide.
wait
for each part in the model, set transparency and cancollide again.
wait

1 Like

You should use a for-loop. Loop through the children of your model and change the properties.

local Model = game.Workspace.Stage1

    while true do
    	for _, parts in pairs(Model:GetChildren()) do
    		if parts:IsA("BasePart") then
    			parts.Transparency = 1
                parts.CanCollide = false
    			wait(10)
    			parts.Transparency = 0 
                parts.CanCollide = true
                wait(10)
    		end
    	end
    end

Edit forgot the wait()

1 Like
local Switch = false
while true do
	for i, v in pairs(workspace.Stage1:GetChildren()) do
		if v:IsA'BasePart' then
			v.CanCollide = Switch
			v.Transparency = Switch and 0 or 1
		end
	end
	Switch = not Switch
	wait(10)
end