Proximity prompt will not connect a function

So I have this dude, like a shopkeeper, and inside his model is a proximity prompt. But when I trigger it, my script does not work, nor does it give me errors or whatever I asked it to print. Looks fine to me. What is wrong? Thank you.


local ProximityPrompt = script.Parent
local GUI = game:GetService("StarterGui")
local ShopGui = GUI.ShopGui.MainFrame
local DB = false

function Triggered()
	print("1st")
	if not DB then
		print("2nd")
		DB = true	
		ProximityPrompt.Enabled = false
		ShopGui.Visible = true

		wait(1)
		DB = false
	end
end

ProximityPrompt.Triggered:Connect(Triggered)
1 Like

I know the problem I have come across this alot when I was starting out. You are saying Starter Gui But it actually gets copied to the players gui so instead of saying “startergui” you have to get the player and access their player gui.

changed it to the player gui, still nothing.

local ProximityPrompt = script.Parent
local GUI = game.Players.LocalPlayer.PlayerGui
local ShopGui = GUI.ShopGui.MainFrame
local DB = false

function Triggered()
	print("1st")
	if not DB then
		print("2nd")
		DB = true	
		ProximityPrompt.Enabled = false
		ShopGui.Visible = true

		wait(1)
		DB = false
	end
end

ProximityPrompt.Triggered:Connect(Triggered)

Try this:

local ProximityPrompt = script.Parent

local DB = false

ProximityPrompt.Triggered:Connect(function(player)
	local GUI = player.PlayerGUI
	local ShopGui = GUI.ShopGui.MainFrame
	print("1st")
	if not DB then
		print("2nd")
		DB = true	
		ProximityPrompt.Enabled = false
		ShopGui.Visible = true
		wait(1)
		DB = false
	end	
end)

also I may be busy in a little so I may not respond

Still not working, very weird. Don’t respond if your busy btw, this can wait.

Are you doing this on a local script? try it on a normal script.
Also I’m not busy thought I might have been but i’m good for now.

I figured out the problems.

  1. I’m dumb and put PlayerGUI its PlayerGui
  2. I just tested this and it does not work in a local script you have to use a server script
    side note: if you want to make it so that the gui says things then you can use a remote event to connect when they trigger the proximity prompt to your local script inside of your screen gui to change the text. it may sound like alot of work but its really easy.

Hope This Solved Your Problem!

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