How to replicate CollectionService tags when objects with the tag are not loaded on the client

Hi!

I’m creating a game, where ProximityPrompts HoldDuration time is constantly being modified by the client. The ProximityPrompts are tagged, so the client knows which prompts hold duration to edit.

So, my problem is that, when player spawns outside the main game area, the tags are not replicated, because the objects with these tags are not loaded on the client side. I would not want to disable StreamingEnabled option, so is there any other way to go about it?

Here’s a code snippet that I use to get all tags, I was also wondering if there’s a more “dynamic” way of doing it, but couldn’t figure a way. I think there may be a easy solution that I may be missing.

local TrashCan = Collection:GetTagged("TrashCan")
local Dumpster = Collection:GetTagged("Dumpster")

local function SetHoldTime(Tag, Time)
	local AllStuffFromTag = Collection:GetTagged(Tag)
	for i,v in ipairs(AllStuffFromTag) do
		v.HoldDuration = Time
	end
end


--start setting
local TrashCanSpeed = DefaultWaitTime/TrashDivingSpeed.Value
SetHoldTime("TrashCan", TrashCanSpeed)
local DumpsterSpeed = DefaultWaitTime + 3/TrashDivingSpeed.Value
SetHoldTime("Dumpster", DumpsterSpeed)

Hi, I still didn’t find a solution! Any help would be would be appreciated!

Tags created on the server should replicate to the client, I think the issue you’re experiencing is because the Instance hasn’t yet loaded for the client when trying to fetch it. To fix this you can use CollectionService’s GetInstanceAddedSignal method/event in order to be able to retrieve the Instance when it has finished loading

Edit for more info: CollectionService also has a GetInstanceRemovedSignal which you can use to detect when the Instance is destroyed or streamed out:

1 Like