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

:IsA returning a nil value?

Asked by 8 years ago

I have ran into a tricky situation. I am using :IsA() to find anything with the Tool ClassName inside a folder, which is due to multiple tools inside the folder. I do not know what is causing the error.

Output: 15:27:55.917 - ServerScriptService.MainGameScript:290: attempt to call method 'IsA' (a nil value) 15:27:55.918 - Stack Begin 15:27:55.918 - Script 'ServerScriptService.MainGameScript', Line 290 15:27:55.918 - Stack End

Code:

CBBToolsFolder = MinigameTools.ClassicBrickbattle

CBBTools = CBBToolsFolder:GetChildren()

if CBBTools:IsA("Tool") and CurrentMap.MapName.Value == "Classic Brickbattle" then
for i = 1, #Player do
        CBBTools:Clone().Parent = Player[i].Backpack
    end
end

1 answer

Log in to vote
4
Answered by 8 years ago

You can't call :IsA() on a table. Here's a fixed code:

CBBToolsFolder = MinigameTools.ClassicBrickbattle

CBBTools = CBBToolsFolder:GetChildren()

for i, v in pairs(game:GetService("Players"):GetPlayers()) do
    for x, y in pairs(CBBTools) do
        if y:IsA("Tool") and CurrentMap.MapName.Value == "Classic Brickbattle" then
            y:clone().Parent = v.Backpack
        end
    end
end

If this helped, please accept!

0
It helped! Thanks Raven_Caedes 95 — 8y
0
@ModifiedBlox No problem! RepeatLua 90 — 8y
Ad

Answer this question