#it says in output "attempt to index nil to :Disconnect()"

1 messages · Page 1 of 1 (latest)

violet sparrow
#

hey chat why does it say that the connection doesn't exist

spawn(function()
    RunService.RenderStepped:Connect(function()
        if hiding == true then
            for i = 1,#plrs do
                for _, v in plrs[i]:GetChildren() do
                    if v:IsA("BasePart") then
                        v.Transparency = 1
                    elseif v:IsA("Decal") then
                        v.Transparency = 1
                    elseif v:IsA("Accessory") then
                        v.Handle.Transparency = 1
                    end
                end
                Connection = plrs[i]:FindFirstChild("Humanoid").Died:Connect(function()
                    for _, v in plrs[i]:GetChildren() do
                        if v:IsA("BasePart") then
                            v.Transparency = 1
                        elseif v:IsA("Decal") then
                            v.Transparency = 1
                        elseif v:IsA("Accessory") then
                            v.Handle.Transparency = 1
                        end
                    end
                end)
            end
        else
            for i = 1,#plrs do
                for _, v in plrs[i]:GetChildren() do
                    if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then 
                        v.Transparency = 0
                    elseif v:IsA("Decal") then
                        v.Transparency = 0
                    elseif v:IsA("Accessory") then
                        v.Handle.Transparency = 0
                    end
                end
            end
            Connection:Disconnect()
        end
    end)
end)
lean bough
violet sparrow
#

oh right uhh i should have mentioned

#

Connection is an empty variable declared isnide the loop

lean bough
#

I don't think you're supposed to disconnect connections inside the connection

violet sparrow
#

bro its not inside the connection

lean bough
#

Is this the full code?

violet sparrow
#

no

violet sparrow
harsh dagger
#

Maybe cus youre Disconnecting it in the else section

violet sparrow
#

like

#

wdym by that

harsh dagger
#

Connection doesnt exist in the part where u disconnect

#

Check studios does the Connection have a red underline?

violet sparrow
#

nope

#

wait actually i think i figured it out

#

because it runs constantly

#

and the connection is only created when hiding becomes true

#

which by default isn't

#

i'd just have to make it so that it checks if said connection exists

#

am i right?

violet sparrow
#

ok guys i fixed it