I am trying to make a script which functions similar to buttons in Flood Escape 2; once pressed, a certain feature of a level is revealed allowing for the players to advance. This is my current script:
local Pressed = script.Parent.Pressed
local Unpressed = script.Parent.Unpressed
local Activated = script.Parent.Parent.Activated
local Reverse = script.Parent.Parent.Reverse
if Reverse.Value == false then
for _, child in ipairs(Activated:GetChildren()) do
child.Transparency = .5
child.CanCollide = false
end
else
for _, child in ipairs(Activated:GetChildren()) do
child.Transparency = 0
child.CanCollide = true
end
end
Pressed.Touched:Connect(function()
if Pressed:FindFirstChildWhichIsA("Humanoid") then
Pressed.Transparency = 1
Unpressed.Transparency = 1
if Reverse.Value == false then
for _, child in ipairs(Activated:GetChildren()) do
child.Transparency = 0
end
else
for _, child in ipairs(Activated:GetChildren()) do
child.Transparency = 1
end
end
end
end)
And this is the hierarchy in which the script is:
The script, however fails to fire at line 18:
Pressed.Touched:Connect(function()
I have tried putting a break point for the first line within that code block, which does not fire, as well as at the beginning to see where the script could be bugging out, however the script runs through the “if Reverse.Value == false then” code block flawlessly, and reaches the end.
What can I do to make the “Pressed” block of the script work?