StreamingEnabled breaking my loop script

I’ve got a script that basically does a workspace:GetDescendants() to see if theres a clickdetector and it works fine without StreamingEnabled yet it doesnt with it, can someone help?

Well, I’m afraid the only way is to redo the script to support StreamingEnabled.

Sorry for the late reply but you can try using:

workspace.DescendantAdded:Connect(function(descendant)
     print(descendant)
     if (descendant:IsA("ClickDetector")) then
         print("Detected a click detector")
     end
end)

Kinda a basic and bland way to do it but whatevs.

2 Likes

Am I right to assume that this is a LocalScript? Would you be able to provide more details like what you’re trying to achieve so we might be able to provide alternatives as fixes?

Sorry for the late response, but basically I use

for _,a in pairs(workspace:GetDescendants()) do
if a:IsA(“ClickDetector”) then

to get Click Detectors but with streaming enabled this doesn’t work, should I use descendantAdded?

I don’t know exactly how your script works or what it does, but it’s possible the click detectors (i.e. most likely the bricks containing the detectors) are out of the streaming range from the player and therefore aren’t loading in for the client. The script then thinks the click detectors don’t exist because it can’t see them. What happens when you run the script with and without StreamingEnabled?

This didn’t answer my questions, would you like me to phrase them differently? If you’re using a LocalScript, I imagine you’re failing to find them all because of part streaming which basically makes the parts that these detectors are in nonexistent unless they’re loaded.