Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

i want to make loading assets to my game but it;s error can you fix it??

Error code:

14:32:01.112 - The current identity (2) cannot Class security check (lacking permission 6)

14:32:01.113 - Stack Begin

14:32:01.113 - Script 'ReplicatedFirst.loading', Line 11

14:32:01.115 - Stack End

My script:

script.Parent:RemoveDefaultLoadingScreen()

local loadingScreen = script.loading
loadingScreen.Parent = game.Players.LocalPlayer.PlayerGui

local contentProvider = game:GetService("ContentProvider")
local toLoad = game:GetDescendants()

local total = #toLoad
for i, v in pairs(toLoad) do
	loadingScreen.background.counter.Text = "Loading: "..i.."/"..total.." "..v.Name
	loadingScreen.background.loadingBar.progress.Size = UDim2.new(i/total, 0, 1, 0)
	contentProvider:PreloadAsync({v})
end

wait(1)
loadingScreen:Destroy()

2 comments

0

Using game:GetDescendants() will also attempt to extract data from core scripts and core gui.

0

Try to get the data separately.

1 answer

✓ Accepted answer

#SOLVING

Use a pcall function so it will skip over the error.

#SCRIPTING


game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local loadingscreen = script.Parent.loading
local RunService = game:GetService("RunService")
local ContentProvider = game:GetService("ContentProvider")

local Descendants = game:GetDescendants()
	
for i, v in pairs(Descendants) do
	local sucess, errormessage = pcall(function()
		ContentProvider:PreloadAsync({v})
	
	    loadingscreen.Text = "loading: " .. i .. " / " .. #game:GetDescendants()
	end)
end

game:GetService("Debris"):AddItem(loadingscreen, 2)

This discussion is preserved as it was. New answers, comments, and votes are closed.