Parts not not collideing

I would like after the intermission timer is up you would fall through the lobby.
This is the script

text = script.Parent.TextLabel

function Intermition()
for i = 10, 0, -1 do
		local lobby = workspace.Lobby:GetChildren()
		text.Text = "STARTING IN ".. i
		wait(1)
		if i == 0 then
			lobby.CanCollide = false --⚠️This is the part that does not work 
			wait(1) -- Alltheway 
			lobby.CanCollide = true --to here⚠️
			Start()
		end
	end
end
function Start()
	for n = 60, 0, -1 do
		text.Text = "TIME LEFT ".. n
		wait(1)
		if n == 0 then
			Intermition()
		end
	end
end
Intermition()

This is what happens
robloxapp-20220530-2213001.wmv (3.7 MB)
The lobby is a free model

1 Like

I dont believe you are calling all the children of the lobby correctly. Follow this way here it should help you get all the parts of the model lobby:

I tried this and it still would not work

text = script.Parent.TextLabel

function Intermition()
print("Intermition")
local lobby = game.workspace.Lobby:GetChildren()
lobby.CanCollide = true
for i = 10, 0, -1 do
		text.Text = "STARTING IN ".. i
		wait(1)
		print("i = "..i)
	end
	lobby.CanCollide = false
	Start()
	print("lobby is cannotcollide")
end
function Start()
	print("Start")
	for n = 60, 0, -1 do
		text.Text = "TIME LEFT ".. n
	wait(1)
	print("n = "..n)
		if n == 0 then
			Intermition()
		end
	end
end
Intermition()



Well, assuming the lobby is a model, we could create a recursive loop to handle the situation.
A recursive loop is basically a function that repeats itself until it reaches a desired value.

local function modelCanCollide(instance,bool)
	for i,v in pairs(instance:GetChildren()) do
		if v and v:IsA("BasePart") then
			v.CanCollide = bool
		end
		modelCanCollide(v,bool)
	end
end

Now that we got a recursive loop that disables collision from a model and it’s parts by reading it’s children and instructing them to do the same, we could apply it within’ your script.

text = script.Parent.TextLabel
lobby = workspace.Lobby
function modelCanCollide(instance,bool)
	for i,v in pairs(instance:GetChildren()) do
		if v and v:IsA("BasePart") then
			v.CanCollide = bool
		end
		modelCanCollide(v,bool)
	end
end
function Intermition()
for i = 10, 0, -1 do
		text.Text = "STARTING IN ".. i
		wait(1)
		if i == 0 then
			modelCanCollide(lobby,false)
			wait(1) -- Alltheway 
			modelCanCollide(lobby,true)
			Start()
		end
	end
end
function Start()
	for n = 60, 0, -1 do
		text.Text = "TIME LEFT ".. n
		wait(1)
		if n == 0 then
			Intermition()
		end
	end
end
Intermition()
1 Like

This is a simpler version of what the other guy did. Just in case you have not found the solution yet. You can’t set the collision of a model, instead we have to loop through each individual part of the Lobby and set each one’s collision to false.

function Intermition()
    local lobby = workspace.Lobby:GetChildren()
    for i = 10, 0, -1 do
		text.Text = "STARTING IN ".. i
		wait(1)
    end
	for i, v in pairs(lobby) do -- loop through Lobby
        if v:IsA("BasePart") then -- if the child is a part then...
           v.CanCollide = false -- set its collision to false
        end
    end
		wait(1) -- Alltheway 
		lobby.CanCollide = true 
		Start()
	end
end

Let me know if there are any issues!

Hey, just a heads up the reason why I made it a recursive loop is that not only he disables the lobby once but he enables it again after a second.

I thought of recursive loops since they can be re-used at any point in time like loops + can be changed with variables that are passed on the function itself.