Script changes only certain parts properties

So for some reason my script doesn’t work fully as it only changes like 3 parts properties and doesn’t do anything else

I’ve printed the part’s parent, says BlizzardSquareObby
Then the part’s transparency, says 0
I don’t get what’s going on??? Can anyone help me with this?

local snowfallStart
local blizzardObby
local blizzardSquare

task.spawn(function()
	while true do
		snowfallStart = workspace:FindFirstChild("SnowfallStart")
		blizzardObby = workspace:FindFirstChild("BlizzardSquareObby")
		blizzardSquare = workspace:FindFirstChild("SnowArea")
			:FindFirstChild("Snow Area Squares"):FindFirstChild("Blizzard Square")
		task.wait()
	end
end)

for _, part: BasePart in blizzardObby:GetChildren() do
	if part:IsA("BasePart") then
		part.Transparency = 1
		part.CanCollide = false
	end
end

blizzardObby.ChildAdded:Connect(function(part: BasePart)
	if part:IsA("BasePart") then
		part.Transparency = 1
		part.CanCollide = false
	end
end)

repeat
	task.wait()
until blizzardSquare
print("Blizzard Square exists")

for _, decal: Decal in blizzardSquare:GetChildren() do
	if decal:IsA("Decal") then
		print(decal)
		decal.Transparency = 1
	end
end
blizzardSquare.CanTouch = false

repeat
	task.wait()
until snowfallStart
print("SnowfallStart exists")

local clickDetector = snowfallStart:FindFirstChild("ClickDetector")

local player = game.Players.LocalPlayer

clickDetector.MouseClick:Connect(function(player)
	print("Starting snowfall")
	
	local emitterPart
	
	repeat
		emitterPart = workspace:FindFirstChild("SnowfallEmitter")
		task.wait()
	until emitterPart
	
	print("Emitting snowfall particles")
	for i, particle in emitterPart:GetChildren() do
		if particle:IsA("ParticleEmitter") then
			particle.Enabled = true
			print("Enabled snowfall emitter #" .. i)
			if i >= #emitterPart:GetChildren() then
				print("All snowfall emitters enabled!")
			end
		end
	end
	
	repeat
		task.wait()
	until blizzardSquare
	
	for _, decal: Decal in blizzardSquare:GetChildren() do
		if decal:IsA("Decal") then
			decal.Transparency = 0
		end
	end
	blizzardSquare.CanTouch = true
	
	-- Starts here
	for _, part: BasePart in blizzardObby:GetChildren() do
		if part:IsA("BasePart") then
			print(part.Parent)
			part.Transparency = 0
			part.CanCollide = true
			print(part.Transparency)
		end
	end

	blizzardObby.ChildAdded:Connect(function(part: BasePart)
		if part:IsA("BasePart") then
			print(part.Parent)
			part.Transparency = 0
			part.CanCollide = true
			print(part.Transparency)
		end
	end)
end)
-- Roblox Services --
local PlayerService = game:GetService("Players")

-- Player Instances --
local player = PlayerService.LocalPlayer

-- Workspace Instances --
local snowfallStart = workspace:WaitForChild("SnowfallStart", 600)
local clickDetector = snowfallStart:WaitForChild("ClickDetector", 600)

local blizzardObby = workspace:WaitForChild("BlizzardSquareObby", 600)
local emitterPart = workspace:WaitForChild("SnowfallEmitter", 600)

local snowArea = workspace:WaitForChild("SnowArea", 600)
local snowSquare = snowArea:WaitForChild("Snow Area Squares", 600)
local blizzardSquare = snowSquare:WaitForChild("Blizzard Square", 600)

-- Variable Values --
local obbyStarted = false

--------------------------------------------------

local function EnableSnowfallParticles()
	for i, particle in emitterPart:GetChildren() do
		if particle:IsA("ParticleEmitter") then
			particle.Enabled = true
		end
	end
end

local function ChangeBlizzardDecal(decal: Decal)
	if decal == nil or (decal and not decal:IsA("Decal")) then
		return
	end
	
	if obbyStarted == true then
		decal.Transparency = 1
	elseif obbyStarted == false then
		decal.Transparency = 0
	end
end

local function ChangeBlizzardPart(part: BasePart)
	if part == nil or (part and not part:IsA("BasePart")) then
		return
	end
	
	if obbyStarted == true then
		part.Transparency = 0
		part.CanCollide = true
	elseif obbyStarted == false then
		part.Transparency = 1
		part.CanCollide = false
	end
end

local function UpdateBlizzardInstances()
	for _, part in blizzardObby:GetChildren() do
		ChangeBlizzardPart(part)
	end

	for _, decal in blizzardSquare:GetChildren() do
		ChangeBlizzardDecal(decal)
	end
end

--------------------------------------------------

-- Signal Connections --
blizzardObby.ChildAdded:Connect(function(part)
	ChangeBlizzardPart(part)
end)

clickDetector.MouseClick:Connect(function(player)
	obbyStarted = true
	blizzardSquare.CanTouch = true

	EnableSnowfallParticles()
	UpdateBlizzardInstances()
end)

-- Initialization --
blizzardSquare.CanTouch = false
UpdateBlizzardInstances()
1 Like

I’ll try this out, thanks!

1 Like