My problem is, the doors do not switch between visible and Cancolide when the bool value is active. The error says OpenParts is a nil value
I have two doors, they are seperate grouped objects.
There is a closed door and an open door. This script is in the open door.
If the bool value is active then this happens The door is visible and can be collided with.
Parts.Transparency = 0 MainPart.CanCollide = true
The closed door is not CanCollide and is invisible but if the bool value is not true then the open door is invisible
Interact = script.Parent.Parent.Door.Interact
MainPart = script.Parent.MainPart
function GetOpenParts() ------Open Door
for i, v in pairs(script:GetChildren()) do
if v:IsA("Part")or ("WedgePart") then return v end
end
return nil
end
function GetClosedParts() ------Closed Door
for i, v in pairs(script.Parent.Parent.Door:GetChildren()) do
if v:IsA("Part")or ("WedgePart") then return v end
end
return nil
end
ClosedParts = GetClosedParts()
OpenParts = GetOpenParts()
if game.Workspace.GameSetup.Home.Values.DoorOpen == true
then
OpenParts.Transparency = 0
MainPart.CanCollide = true
ClosedParts.Transparency = 1
Interact.CanCollide = false
else
ClosedParts.Transparency = 0
Interact.CanCollide = true
OpenParts.Transparency = 1
MainPart.CanCollide = false
end

2 comments
This helped, thankyou.
You're welcome.