How to 'reset' a proximity prompts Trigger?

Hi,

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)

robloxapp-20211114-2002129.wmv (1.3 MB)

I think this is what you are doing wrong:

  • 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.

Sadly thats not what im doing, I close it in a similar fashion in a local script inside my StarterGui

script.Parent:WaitForChild("ShopBtn").MouseButton1Click:Connect(function()
	if script.Parent:WaitForChild("Shop").Visible == false then
		script.Parent:WaitForChild("Shop").Visible = true
		script.Parent:WaitForChild("GPShop").Visible = false
		script.Parent:WaitForChild("GamePass").Visible = false
	else
		script.Parent:WaitForChild("Shop").Visible = false
	end
	
end)

(Thats for the button i press to close the shop in the video)

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”.

Thanks for the reply, changed it to this but it still didnt seem to work:

local playerGui = player.PlayerGui.ScreenGui.MainGUI
playerGui:WaitForChild("ShopBtn").MouseButton1Click:Connect(function()
	if playerGui:WaitForChild("Shop").Visible == false then
		playerGui:WaitForChild("Shop").Visible = true
		playerGui:WaitForChild("GPShop").Visible = false
		playerGui:WaitForChild("GamePass").Visible = false
	else
		playerGui:WaitForChild("Shop").Visible = false
	end
	
end)

Make sure those references are correct, also:

player:WaitForChild("PlayerGui").ScreenGui.MainGUI.Shop

You haven’t defined “player”. You can use “game.Players.LocalPlayer” since it’s a local script.

I defined it as player = game.Players.LocalPlayer further up in the script. Swapped it to WaitForChild also, still not working sadly

Players.LocalPlayer - local player is a property, you can’t use :WaitForChild() on it

No, I swapped player.PlayerGui to player:WaitForChild(“PlayerGui”)

PlayerGui changes should be done in a local script
use remoteEvents

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?

for “a normal script”, your referring to serverscripts right? because you can still make a function to detect the triggered aspect in a localscript.