local SetOne = script.Parent
local Button2 = game.Workspace.Button3
local Button3 = game.Workspace.Button3
local SetTwo = Button2 and Button3
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
SetTwo.Transparency = 0
end
script.Parent.Touched:connect(onTouch)
Both of your buttons are assigned to the same part, plus the “and” function doesn’t work this way:
local SetOne = script.Parent
local Button2 = game.Workspace.Button2
local Button3 = game.Workspace.Button3
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
Button2 .Transparency = 0
Button3 .Transparency = 0
end
script.Parent.Touched:connect(onTouch)
Yes, but if you really wanted to, you could create a table then do a for loop:
local SetOne = script.Parent
local Button2 = game.Workspace.Button2
local Button3 = game.Workspace.Button3
local SetTwo = {
A = Button2,
B = Button3
}
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
for i,v in pairs(SetTwo) do
v.Transparency = 0
end
end
script.Parent.Touched:connect(onTouch)
local setOne = script.Parent
local setTwo = {
workspace.Button2,
workspace.Button3
}
function onTouch(part)
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
for _, button in ipairs(setTwo) do
button.Transparency = 0
end
end
setOne.Touched:Connect(onTouch)
code with PascalCase
local SetOne = script.Parent
local SetTwo = {
workspace.Button2,
workspace.Button3
}
function OnTouch(Part)
local Humanoid = Part.Parent:FindFirstChildOfClass("Humanoid")
for _, Button in ipairs(SetTwo) do
Button.Transparency = 0
end
end
SetOne.Touched:Connect(OnTouch)
made some changes to the code
also choose camelCase or PascalCase, don’t just mix both of them