luarobloxlua-userdata

Attempt to call a userdata value


So i'm trying to make a part disapear when the player touch it but it says : Workspace.RedCastle.Grid.Script:1: attempt to call a userdata value

Here's my code :

script.Parent.Part.Touched(function(part)
    for i, part in pairs(script.Parent.Parts:GetChildren()) do
        part.CanCollide = false
        part.Transparency = 1
    end
    wait(5)
    for i, part in pairs(script.Parent.Parts:GetChildren()) do
        part.CanCollide = true
        part.Transparency = 0
    end
end)

How can i fix this?


Solution

  • script.Parent.Part.Touched:Connect(function(part)
        for i, part in pairs(script.Parent.Parts:GetChildren()) do
            part.CanCollide = false
            part.Transparency = 1
        end
        wait(5)
        for i, part in pairs(script.Parent.Parts:GetChildren()) do
            part.CanCollide = true
            part.Transparency = 0
        end
    end)