You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i want this function to simply work
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)
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.
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().
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)
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
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.