The current thread cannot access 'StreamingService' (lacking capability Assistant)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want this function to simply work
  2. What is the issue? Include screenshots / videos if possible!
    its giving the error “The current thread cannot access ‘StreamingService’ (lacking capability Assistant)” on line 28 of the module (marked in the code below)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    ive looked through the dev forum and found ONE post, witch was reporting this as an engine bug,
    ive tried doing if v.Name ~= “StreamingService” but it dosent do anything and the error still occurs.

any fixes?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
the function

module.ClearAttribute = function(plr)
	for i,v in pairs(game:GetDescendants()) do

		if v:GetAttribute("Ownership") == plr.Name then --line 28
			if v.Name ~= "dang" then
				v:Destroy()
			else
				v:Destroy()
				if not game.Lighting:FindFirstChild("dang") then
					local sky = script.Sky:Clone()
					sky.Parent = game.Lighting
					game.Lighting.Brightness = 1
					game.Lighting.Ambient = Color3.fromRGB(244,244,244)
				end
			end
		end
	end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

5 Likes

You probably want to be looking over workspace, not the entire game.

A lot of the instances under game are hidden and locked and stuff.

So just change game:GetDescendants() to workspace:GetDescendants()

3 Likes

just wrap the if statement inside the loop into a pcall, it avoids the issue (literally just remembered pcalls existed lol)

3 Likes

I started getting the “The current thread cannot access ‘StreamingService’ (lacking capability Assistant)” error today in code which I haven’t even touched in months.

It seems in the latest studio update they made game.StreamingService error out if you try to access anything in it, even doing print(game.StreamingService.Name) will trigger this error. Sad as it’s easy to accidentally do in any run-once prep script which steps through game:GetDescendants().

1 Like

alright after further debugging i found out streaming service is the 66th child of game, so checking if it’s the 66th iteration and skipping it when looping with ‘game:GetChildren()’ will avoid the error.

local _, success = pcall(function()
	
	for i, v in pairs(game:GetChildren()) do 
		
		if i > 66 or i < 66 then
			
			print(i, v)
			
		end
		
	end
	
end)

I am getting this issue in Studio as well with code that has been untouched. I think it’s a bug.

1 Like

i have objects to clear from thing within other services aswell

tried that and it still dosent work

also note that this error only happens in studio, not in game. it just makes testing 10x harder

oh wait, try 65 then, as i have a folder in game, which made the total child count of game 107 instead of 106.

As @BendsSpace said, just wrap it in pcall. Because relying on this service number is not safe, if roblox adds another one the error will reappear.

module.ClearAttribute = function(plr)
	pcall(function()
		for i,v in pairs(game:GetDescendants()) do

			if v:GetAttribute("Ownership") == plr.Name then --line 28
				if v.Name ~= "dang" then
					v:Destroy()
				else
					v:Destroy()
					if not game.Lighting:FindFirstChild("dang") then
						local sky = script.Sky:Clone()
						sky.Parent = game.Lighting
						game.Lighting.Brightness = 1
						game.Lighting.Ambient = Color3.fromRGB(244,244,244)
					end
				end
			end
		end
	end)	
end

that may work, but i just used a pcall as someone suggest above

ex:

module.ClearAttribute = function(plr)
	for i,v in pairs(game:GetDescendants()) do
		local er,suc = pcall(function()
			
		if v:GetAttribute("Ownership") == plr.Name then
			if v.Name ~= "dang" then
				v:Destroy()
			else
				v:Destroy()
				if not game.Lighting:FindFirstChild("dang") then
					local sky = script.Sky:Clone()
					sky.Parent = game.Lighting
					game.Lighting.Brightness = 1
					game.Lighting.Ambient = Color3.fromRGB(244,244,244)
				end
			end
		end
		end)
	end
end

ironic timing as i jsut used a pcall

2 Likes

yeah, though i found it errored at the 65th iteration even with the pcall, which is why i added the if statement.

This is a bug with the latest version of studio which is expected to be fixed in a week or so (see linked post), if you need a work around ASAP pcall is probably your only option for now.

2 Likes

using the pcall around the area where it loops the instances worked for me, not sure why it’d break

just make sure your using the pcall correctly around it

this is the post i was talking about in the post, glad its getting fixed soon

1 Like

oops, i meant it just stops at the 65th iteration, not errors, i just wanted to loop through all the children in game without that silent error.

You probably resolved this already but for anyone looking for a shorter hotfix than pcall you can simply skip an item if it’s StreamingService itself.

for i, v in ipairs(game:GetChildren()) do
	if v == game:GetService("StreamingService") then continue end -- Engine bug hotfix
	-- (your code here)
end
1 Like

oh thanks, i like this shorter version, it’ll keep my code clean.

1 Like