CollectionService, GetInstanceAddedSignal doesn't respond

I tried to make kill brick in Roblox Studio for my game, using “GetInstanceAddedSignal”, but it didn’t work and I found it really odd, I thought I made some typo, but clearly not, I asked other devs about it, they couldn’t find any issue here too, so I suggest it may be a studio bug, I tried to debug but it completely skips it, I tried to do it in clear workspace, reinstalled studio and turning off plugins.
But nothing works, I debugged it, works but doesn’t send signal so it skips function on video.

Maybe I’m wrong, but I tried using official docs example with deadly brick, it doesn’t work too: CollectionService | Documentation - Roblox Creator Hub

Also checked recent posts on Dev Forum couldn’t find something relatable, so now reporting it.

Here is my code:

local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local RunService = game:GetService("RunService")

--Modules:
local Modules = ServerStorage.Modules

--Functions

-- Connect to Laser tag additions
CollectionService:GetInstanceAddedSignal("Laser"):Connect(function(part)
	local function onTouched(otherPart)
		local character = otherPart.Parent
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid:TakeDamage(10)
		end
	end

	part.Touched:Connect(onTouched)
end)

Expected behavior

I expected my humanoid to get damage or print any result from function, but it skips it when I debug it.

Edit: Forgot to add, that when I ran Roblox Official Documentation example, it takes longer for studio and overall using GetInstanceAddedSignal makes studio longer to load.

It looks like you’ve already set the “Laser” tag on the parts while in edit mode. GetInstanceAddedSignal would fire when “Laser” is added, during runtime, to a part that doesn’t already have the tag.

Instead, try using GetTagged to get a table of all parts that already have the tag, for example:

for _, part in CollectionService:GetTagged("Laser") do
    if part:IsA("BasePart") then
        part.Touched:Connect(function(hit)
            print("touched")
        end)
    end
end
3 Likes

Yeah I guess my bad, I never worked with this, I’ll use different method.