I have a shop that opens using a proximity prompt with the following code:
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local shop = player:WaitForChild("PlayerGui").ScreenGui.MainGUI.Shop
if shop.Visible == false then
shop.Visible = true
end
end)
It works, however when I close the shop using the shops own exit buttons, when i next want to open the shop using the NPC, the proximity prompt wont work anymore. Any ideas how to fix this? (Video attached)
When you close the gui with the exit button then you are setting the gui disabled like this:
Screengui.Enabled = false
But when you open with the proximity prompt you are setting the frame to visible like this:
Screengui.Frame.Visible = true
When you are setting the the frame to visible while the gui is disabled you won’t see anything. So be sure you are not disabling the gui instead of making the frame not visible.
You’re turning off visibility of the “Frame” instance when using the shop through the “StarterGui” folder, however when you enable visibility of the same “Frame” instance with the proximity prompt you’re doing it through the player’s own “PlayerGui”. This means that when the prompt is triggered the visibility of “PlayerGuI.ScreenGui.MainGUI.Shop” is set to true (if false) and is never set back to false (even when disable the visibility of the “Frame” instance inside the “StarterGui”.
Change the references in the 2nd script to work with “PlayerGui”.
For the close button, this is done in a local script. On a post I looked at a while ago for proximity prompts, apparently a normal script must be used to detect the Triggered aspect of the prompt. How would remote events be able to reenable the proximity prompt to work correctly?