Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
6 years ago

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

Ad

Answer this question