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

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

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

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)

1 comment

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')

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