Obby appearing when player steps on part, bugs after repeated use

Alright, so I have this code, where if a player steps on the white platform part (in the video) an obby appears

However, as you can see in the video, sometimes this breaks completely. I have no idea why, because it should be a local script, nothing to do with the server, local loading appears broken and I don’t know why that would be the case. I will provide the code to the function that makes all of the parts appear.

The script I am using is a local script inside a screengui (which doesn’t reset upon death, due to a feature in the script).

-- // THIS IS WHAT MAKES THE OBBY APPEAR\\ --
local function start()
		tween(false, plr.PlayerGui.Timer.TimeText) -- this just makes a timer text appear,
          -- I have a timer for this obby
		for _, obj : BasePart in partsFolder:GetDescendants() do
			if obj:IsA('BasePart') then
				game:GetService('TweenService'):Create(obj, TweenInfo.new(.5), {Transparency = 0}):Play()
				obj.CanCollide = true
			
			elseif obj:IsA('Beam') then
				obj.Transparency = NumberSequence.new(0)
			end
		end
	end
	-- // THIS IS WHAT MAKES THE OBBY DISAPPEAR \\ --
	local function End(didntmakeit)
		ended = true
		
		if didntmakeit then
			plr.Character.Humanoid.Health = 0
		end
		
		for _, obj in partsFolder:GetDescendants() do
			if obj:IsA('BasePart') then
				game:GetService('TweenService'):Create(obj, TweenInfo.new(.5), {Transparency = 1}):Play()
				obj.CanCollide = false
			elseif obj:IsA('Beam') then
				obj.Transparency = NumberSequence.new(1)
			end
		end
		tween(true, plr.PlayerGui.Timer.TimeText)
		task.wait(1)
		partsFolder:Destroy()
	end

There was another if statement which checked if the part was a trusspart so it could turn IT invisible aswell, but I figured I could replace it with “BasePart” for every single part instance in the game. The beam is just for the little arrows you see on a typical conveyor belt.

Can someone please help? I’ve been trying to fix this for an hour now.