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

'attempt to index nil with Handle', why is this happening and how to fix?

Asked by 3 years ago

Hello. I was making a script to set a GUI box but this error is appearing when I run it: 'Line 13, attempt to index nil with Handle'. Here is my Script:

local administrators = {
    698511703
}
local WaitTime = 5

local imageList = game.ReplicatedStorage.Permit_Images

game.Players.PlayerAdded:Connect(function(plr)
    for i, v in pairs(administrators) do
        if plr.userId == v then
            local bp = plr.Backpack
            local permit = bp:WaitForChild('Permit', WaitTime)
            local frame = permit.Handle.PermitGui
            local image = imageList.Administrator_Permit:Clone()

            image.Parent = frame
        elseif plr.userId ~= v then
            local bp = plr.Backpack
            local permit = bp:WaitForChild('Permit', WaitTime)
            local frame = permit.Handle.PermitGui
            local image = imageList.Legal_Permit:Clone()

            image.Parent = frame
        end 
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Don't use timeOut and see if that fixes it.

Script:

local administrators = {
    698511703
}

local imageList = game.ReplicatedStorage.Permit_Images

game.Players.PlayerAdded:Connect(function(plr)
    for i, v in pairs(administrators) do
        if plr.userId == v then
            local bp = plr.Backpack
            local permit = bp:WaitForChild('Permit')
            local frame = permit.Handle.PermitGui
            local image = imageList.Administrator_Permit:Clone()

            image.Parent = frame
        elseif plr.userId ~= v then
            local bp = plr.Backpack
            local permit = bp:WaitForChild('Permit', WaitTime)
            local frame = permit.Handle.PermitGui
            local image = imageList.Legal_Permit:Clone()

            image.Parent = frame
        end 
    end
end)
0
I used that to fix infinite yield; now it's saying that ther's a possible Infinite Yield Possible on Players.PufferfishDev.Backpack:WaitForChild('Permit') PufferfishDev 49 — 3y
Ad

Answer this question