-
What do you want to achieve? Keep it simple and clear!
This script is supposed to change the transparency when X is pressed, and then set the transparency back to 0 when X is pressed again.
However, only some doors change transparency? Why is this?
Code:
local C = false
local doors = game.Workspace.Doors
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(Input, gameProcessedEvent)
if gameProcessedEvent == false and Input.KeyCode == Enum.KeyCode.X then
for i,v in pairs(doors:GetDescendants()) do
if v:IsA("BasePart") then
if v.Name == "Door" then
if C == false then -- X to set transparency to .5
v.Transparency = .5
v.CanCollide = false
C = true
elseif C == true then -- X again to set transparency to 0
v.Transparency = 0
v.CanCollide = true
C = false
end
end
end
end
end
end)