Title
So I’ve got a Red Part and a Blue Part, What I’m doing is basically finding parts in the workspace that have a “Dimension” Attribute
I want to make it so that if the “RED” dimension’s part is visible (or collidable in this case) to make the “BLUE” dimension’s part is invisible (or uncollidable in this case)
local descendants = game.Workspace:GetDescendants()
local UIS = game:GetService("UserInputService")
for index, descendant in pairs(descendants) do
local Dimension = descendant:GetAttribute("DIMENSION")
if Dimension == "RED" then
print("Found ".. [["]]..descendant.Name..[["]].. "; Dimension: ".. Dimension)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if descendant.CanCollide == true then
descendant.Transparency = 0.75
descendant.CanCollide = false
elseif descendant.CanCollide == false then
descendant.Transparency = 0.35
descendant.CanCollide = true
end
end
end)
end
if Dimension == "BLUE" then
print("Found ".. [["]]..descendant.Name..[["]].. "; Dimension: ".. Dimension)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if descendant.CanCollide == true then
descendant.Transparency = 0.75
descendant.CanCollide = false
elseif descendant.CanCollide == false then
descendant.Transparency = 0.35
descendant.CanCollide = true
end
end
end)
end
end
also, if there’s any way to make this code look smoother or cleaner