Proximity Prompt only works once

I have this script, how it works is when the player activates the proximity prompt, gui will show up (for just that player) and he can do his thing blah blah blah. But when he closes it using a little close button in the gui, if he were to try to open it again the gui will not show up.

Local Script:


--|MoneyStuff|--
local LocalPlayer = game.Players.LocalPlayer
local leaderstats = LocalPlayer:WaitForChild("leaderstats")
local IntValue = leaderstats.Money
--|MainFrame|--
local MainFrame = script.Parent.MainFrame
--|DiaLogBox|--
local DialogBox = MainFrame.DialogBox
local BuyButton = DialogBox.Buy
local SellButton = DialogBox.Sell
--|BuyBox|--
local BuyBox = MainFrame.Buy
local BuyPizza = BuyBox.Pizza
local BuyWater = BuyBox.Water
--|Other|--
local LocalPlayer = game.Players.LocalPlayer
local DB = false
local rep = game:GetService("ReplicatedStorage")
local PizzaTool = rep.PizzaTool
local WaterTool = rep.WaterTool
local X = MainFrame.X
local ProxEvent = rep.ShopProxToggle

BuyButton.MouseButton1Click:Connect(function(Player)
	if not DB then
	DB = true
	DialogBox.Visible = false
	BuyBox.Visible = true
		wait(1)
	DB = false	
	end
end)

BuyPizza.MouseButton1Click:Connect(function(Player)
	if not DB then
		DB = true
		if IntValue.Value >= 5 then
			IntValue.Value = IntValue.Value - 5
			local NewPizza = PizzaTool:Clone()
			NewPizza.Parent = LocalPlayer.Backpack
			print("Bought")
		end
		    wait(1)
		DB = false
	end
end)

BuyWater.MouseButton1Click:Connect(function(Player)
	if not DB then
		DB = true
		if IntValue.Value >= 2 then
			IntValue.Value = IntValue.Value - 2
			local NewWater = WaterTool:Clone()
			NewWater.Parent = LocalPlayer.Backpack
			print("Bought")
		end
		wait(1)
		DB = false
	end
end)

X.MouseButton1Click:Connect(function(Player)
	if not DB then
	DB = true
	MainFrame.Visible = false
	ProxEvent:FireServer(Player)
		
		wait(1)
	DB = false
	end
end)

ServerScript:

local ProximityPrompt = script.Parent
local Rep = game:GetService("ReplicatedStorage")
local DB = false
local Event = Rep.ShopProxToggle

ProximityPrompt.Triggered:Connect(function(player)
	local GUI = player.PlayerGui
	local ShopGui = GUI.ShopGui.MainFrame
	wait(.1)
		ProximityPrompt.Enabled = false
		ShopGui.Visible = true
	
end)


Event.OnServerEvent:Connect(function()
	ProximityPrompt.Enabled = true
end)

Does the prompt exist when it doesn’t appear? Check workspace and check if it is disabled

The prompt does exist, but when I activate it, the ui does not appear, unlike the first time you use it.

Solved it, just moved everything into one big scritpt.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.