Why isnt this tycoon button working

Help, i cant figure out how to make this tycoon button disappear when it is touched.

can you send the code so I can edit?

yes right here

WB = script.Parent
BB = script.parent.Parent.ButtonBottom
function onTouched(hit)
WB.CanCollide = false
WB.transparency = 1
BB.Transparency = 1
BB.CanCollide = false
end
script.Parent.Touched:connect(onTouched)

local WB = script.Parent
local BB = WB.Parent.ButtonBottom
local Debounce = false

function onTouched(hit)
    if hit and hit.Parent:FindFirstChildWhichIsA("Humanoid") and Debounce == false then
        Debounce = true
        WB.CanCollide = false
        WB.Transparency = 1
        BB.Transparency = 1
        BB.CanCollide = false
        Debounce = false
    end
end

WB.Touched:Connect(onTouched)

this should work

it worked thank you :slight_smile:

np, if you have any more questions feel free to ask

I think I just might, do you know how to make a whole model transparent kinda like when you buy a wall, I know I could use the same method we just used but it would take to long to reference each individual part, so is there a way to make the whole model go from transparent and uncollidable to visible and collidable??

you can do that using i, v loops

for i, v in pairs(model:GetDescendants()) do
    v.CanCollide = false
    v.Transparency = 1
end

O ok thank you, I will try that out