Tried to switch to collection service to be able to update scripts better yet doesn't work

So i tried to update my scripts to be on collection service so i could update them in one script instead of multiple and it just doesn’t work.

New Script (doesn’t work)

local CS = game:GetService("CollectionService")
for i, part in pairs(CS:GetTagged("Door")) do
	print("it works") -- prints this
	part:FindFirstChildOfClass("Attachment"):FindFirstChild("ProximityPrompt").Triggered:Connect(function(player)
		print("it triggered") -- doesn't print this
		local prompt = part.Attachment.ProximityPrompt
		local dooropen = part.DoorOpen
		local ts = game:GetService("TweenService")
		local sound = part.Sound

		local char = player.Character
		local hum = char:FindFirstChildOfClass("Humanoid")
		if hum.Health < 1 then return end
		prompt.MaxActivationDistance = 0
		game.ReplicatedStorage.Door_Open:Fire()
		local door_anim = ts:Create(part,TweenInfo.new(2,Enum.EasingStyle.Circular,Enum.EasingDirection.Out),{CFrame = dooropen.CFrame})
		door_anim:Play()
		sound:Play()
		task.wait(2)
		script.Enabled = true
	end)
end

Original Script (works)

local prompt = script.Parent.Attachment.ProximityPrompt
local dooropen = script.Parent.DoorOpen
local ts = game:GetService("TweenService")
local sound = script.Parent.Sound

prompt.Triggered:Connect(function(player)
	local char = player.Character
	local hum = char:FindFirstChildOfClass("Humanoid")
	if hum.Health < 1 then return end
	prompt.MaxActivationDistance = 0
	game.ReplicatedStorage.Door_Open:Fire()
	local door_anim = ts:Create(script.Parent,TweenInfo.new(2,Enum.EasingStyle.Circular,Enum.EasingDirection.Out),{CFrame = dooropen.CFrame})
	door_anim:Play()
	sound:Play()
	task.wait(2)
	script.Enabled = true
end)
  1. Are you sure the Instance you are tagging is the right one? Make sure your actual door model is the one getting tagged from the looks of it.

  2. If it is printing your first print function but not your second, you should be getting an error since the FindFirst functions does not guarantee an Instance value.

  1. I checked it and yeah it is the correct instance
  2. Nothing in output except for the first print statement

Do me a favor and print these 2 after your first print and observe what they output:

print(part:FindFirstChildOfClass("Attachment"))
print(part.Attachment:FindFirstChild("ProximityPrompt"))

grafik

It is working just fine for me on my end. Are you sure the ProximityPrompt is enabled and you can interact with it, and there is nothing else in between your print and your connection?

the proximityprompt is enabled and it is interactable, and there shouldn’t be anything between the connection

Are you able to send me a repro file? Everything should be working just fine if the statements above are true, and I’ve tested it myself.

what does repro file mean?

(i need to write here bc it doesn’t let me post)

Reproduction file. Send me a place file or a model file of your model and code and see if I get it working on my end with your setup.

huh, so i tried it on a different place and the code worked

(also i have no idea how to send place files)

Hmm, then it may just be a studio bug with proximity prompts somehow. Try restarting your studio in your main place and re-adding your proximity prompt and see if that helps.

restarting studio and re-adding the proximity prompt didn’t help

(i’m really confused)