Can I make many click detectors all follow one script?

I am sure there is a better way to word that question, but basically can one reference like…

local Minis = game.Workspace.RblxMinis
local Sound = script.DING
-----
local Araballa = Minis.ArabellaMiniAva.ClickPart.ClickDetector
local Blossom = Minis["ClickPart(Bloss)"].ClickDetector
local Clay = Minis["ClickPart(Clay)"].ClickDetector
local Jaxin = Minis.JaxinMiniAva.ClickPart.ClickDetector
local Kya = Minis["ClickPart(Kya)"].ClickDetector
local Lexi = Minis.LexiMiniAva.ClickPart.ClickDetector
local Maddy = Minis.MaddyMiniAva.ClickPart.ClickDetector
local Yana = Minis.YanaMiniAva.ClickPart.ClickDetector
-----
local ClickDets = {Araballa, Blossom, Clay, Jaxin, Kya, Lexi, Minis, Yana}

ClickDets.MouseClick:Connect(function()
	Sound:Play()
end)

This sadly doesn’t work like that I suppose since the output keeps saying: Players.KyameronKing.PlayerScripts.ChatRanks.MinisSounds.SoundScript:15: attempt to index nil with 'Connect'' :broken_heart:

Hopefully this question makes sense…

Just so you know, by default, the client loads non-persistent parts in and out of the workspace based on your position to save on memory - this is called streaming. This means your parts may or may not exist when you reference it from the client.

Regardless, you would have to loop through your table then connect each one. Better yet, use CollectionService with a handy tutorial under the Instance Streaming article to take streaming into consideration.

1 Like

I appreciate the reply, thank you for the suggestions and info :>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.