Getting a GUI to appear when I click on a part roblox studio

Solution for Getting a GUI to appear when I click on a part roblox studio
is Given Below:

I was trying to make a game in Roblox studio, and I wanted to make a GUI appear when I click on a part. So far, it will appear, and I also have a button to close it that works. After I close it, for some reason, I can’t open it again. Any ideas? Here is my code:

Opening code:

function Clicked(Plr)
    Plr.PlayerGui.ScreenGuisword.Frame.Visible=true
end

script.Parent.ClickDetector.MouseClick:Connect(Clicked)

Closing code:

script.Parent.MouseButton1Down:Connect(function()


    script.Parent.Parent.Visible = false
end)

Keep in mind that the opening code is a part, and the closing code is a GUI button