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

Got a "Workspace.Script:13: attempt to call method 'IsA' (a nil value)" fix?


sgroup = {}
ggroup = {}
lgroup = {}
tgroup = {}

f = game.Lighting.Npc.Bot
--print(f)
g = f:Clone()
gps = g:GetChildren()
g.Parent = game.Workspace
game:GetService("RunService").RenderStepped:Connect(function()
	for _, v in pairs(sgroup)do
		if v:IsA"Part" then
			--while wait() do
				--for i=1, 2 do
				v.Transparency = v.Transparency + .04
			--end
		end
	end
end)
table.insert(sgroup,1,gps)

1 answer

✓ Accepted answer

The error is saying that sgroup is nil (the list is empty), and that you can't call the method :IsA on a nil value.

sgroup = {}
ggroup = {}
lgroup = {}
tgroup = {}

f = game.Lighting.Npc.Bot
--print(f)
g = f:Clone()
gps = g:GetChildren()
g.Parent = game.Workspace
game:GetService("RunService").RenderStepped:Connect(function()
    for _, v in pairs(sgroup)do
        if v ~= nil and v:IsA('Part') then -- added a v ~= nil which checks if v is not nil
            --while wait() do
                --for i=1, 2 do
                v.Transparency = v.Transparency + .04
            --end
        end
    end
end)
table.insert(sgroup,1,gps) -- make sure that this is a instance your inserting in sgroup and that it has a ClassName so ':IsA()' can determine if it's a part

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