What is this error?

So, while creating a map in a place, i started getting this error:

10:28:37.932  The current identity (2) cannot Class security check (lacking permission 6)

What does it mean?

This started happening after i made this script to teleport the Player to a “Spawn”:

local S = {}

S.AssignedSpawn = "Spawn"

function S.Spawn(c: Model?)
	local Location
	for _,i in pairs(game:GetDescendants()) do
		if i:IsA("Part") and i.Name == S.AssignedSpawn then
			Location = (i.CFrame * CFrame.new(0,2,0))
		end
	end
	return c:PivotTo(Location)
end

return S

Why are you checking the game's descendants? If you want it to teleport the Player to a Spawn, why not just use workspace:GetDescendants()? This is why the error happens.

And thats why this is here. Its only in the workspace, so it shouldnt cause issues

You cannot access some game descendant instances. That’s why they suggested using workspace.

Even then, the iterator accessed some locked Roblox service, which isn’t allowed.

it should check if i is a Part before firing the code

That’s not how it works. Sure, first lines of code have priority, but Roblox added hidden stuff to every function data-type, which causes your issue.

What Service is it accessing? The closest thing I can find is SpawnerService, I have never had any issue doing this

Edit: testing the exact same code from the topic works now for some reason.

Amongst CoreGui, it might also access multiple other normally hidden (in the Explorer) services. They are not accessible if they do not have functions/events/properties open for us to use.

The only thing I can think of is that the iterator found your Spawn part before it found a Roblox-locked service.

Im firing the code when the Player’s Character is added, that shouldn’t be it

Really?

1 Like

the error happens because you are accessing stuff that roblox wouldnt let you to

No, what you’ve been told is exactly the problem here. You cannot index anything on these locked services, not all descendants under game are allowed to be used. When you index that descendant (by calling IsA on it), Roblox throws an error, since it’s forbidden to use the object. You should be using workspace instead of game as previously suggested.

1 Like

Its weird as the error went away, i changed nothing, i tested the code over 30 times, works how i wanted to

You should still fix it. The order in which instances are put is random, and this error will (100%) happen in the future. Just because it works now doesn’t mean that it will in the future - you should fix it.

yes the solution would be to iterate through the workspace for your spawn point not the game Instance. and yeah as mentioned you shouldnt just igrone it now that it randomly disappeared it can occur in the future its always a good practice to fix it now in my opinion.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.