Secret Doorway (Pay)

Secret Doorway

Where to put this Script

In a script in the invisible part in front of the wall or door

Script

local part = script.Parent
local wall = game.Workspace.Wall
local canOpen = true

local function lift(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid and canOpen then
        local player = game.Players:FindFirstChild(partParent.Name)
        local gold = player.leaderstats.Gold.Value
        if player and gold > 100 then
            canOpen = false
            player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - 100
            wall.Transparency = 1
            wall.CanCollide = false 
            wait(2)
            wall.Transparency = 0
            wall.CanCollide = true
            canOpen = true 
        end
    end
end

part.Touched:Connect(lift)