Lacking permissions error

I’m making a script that changes the name of services to something random, but I get this error: The current identity (2) cannot Class security check (lacking permission 6) - Server - Server:50

Here’s the code that errors specifically:

for index, service in pairs(game:GetChildren()) do
	task.wait(1)
	if service then
		service.Name = HTTP:GenerateGUID(true)
		print("Setting "..index.." services to random names")
	end
end

Certain services are restricted (will throw/raise errors when an attempt is made to reference them) so you’ll need to use the pcall() global to handle errors when they arise.

for _, service in ipairs(game:GetChildren()) do
	local success, result = pcall(function()
		service.Name = ""
	end)
	
	if success then
		if result then
			print("Success!")
		end
	else
		warn(result)
	end
end
1 Like