I’ve been confused on why this isn’t working. I am making a showcase, and I put a ProximityPrompt onto an object. The prompt is supposed to open a GUI in StarterGui, but it WON’T WORK!!! HELP
I’m back, and I tested it out. THANK YOU SO MUCH! It worked! This was a really valuable learning experience for me. I’m so grateful for people like you!!!
Ah, one problem though. The prompt only works once. I open the credits GUI, close it, then try to open it with the ProximityPrompt again, and nothing happens. Do you know any way to fix this?
You will need to use something called a debounce. A debounce can be a variable that stores a true and false value which we can change once the UI opens and closes. Also I recommend moving everything to client instead of the server for easier use. Here is an example:
local Debounce = false --Our debounce value
Prompt.Triggered:Connect(function(Player) --Prompt triggered
if Debounce then --Check if debounce is true
--Close UI
else
--Open UI
end
Debounce = not Debounce --Flip the value (If true goes false, if false goes true)
end)
So how would I be able to move everything to the client? Also, where would I put the script you gave me? I’m sure you can tell I’m a beginner scripter lol, I’m not great at this.
You can put the code I provided within a local script. You can put the local script in any client sided service or instance such as StarterGui or StarterPack like shown in this photo.
Running this code on client will mean that any code that is ran (opening our UI) is only shown for the one person behind the device. For example if we create a part within a server script everyone in the game will see the part, if we create a part within a local script only that one person can see the part.
Only problem: I see you have that “Prompt:Triggered” etc. Is that to detect if the prompt is triggered? If so, wouldn’t I want to have that under the Part that I have the ProximityPrompt on? Sorry if it’s obvious, I’m just a little confused.
Yeah I was just using that as my example.
In your case it will be: game.Workspace.YourPart.ProximityPrompt.Triggered:Connect(function()
Alternatively you can define it as a variable local Prompt = game.Workspace.YourPart.ProximityPrompt
Ohhh, okay, so rather than detecting that the Prox. Prompt has been detected from within the part, I put the script in my credits GUI, or places like that. I’ll try that out!
Yes as a developer it’s good to organize code and your instances in places where it would make sense so it’s easier for yourself and others to navigate your workspace. Also local scripts generally do not run within a part.
Wouldn’t that be Prompt.Triggered? I’m getting an error when I have a colon, but when I use a period there isn’t an error. Should I keep it as a colon or change it to a period?
The code that I provided earlier works perfectly fine in my case.
local Prompt = game.Workspace:WaitForChild("Part").ProximityPrompt
local UI = script.Parent
local Debounce = false
Prompt.Triggered:Connect(function()
if Debounce then
UI.Frame.Visible = false
else
UI.Frame.Visible = true
end
Debounce = not Debounce
end)
Can you provide your code so I can help?
Is your debounce value set to false?
Is your frame by default have visible set to false?
Your debounce value should be true or false depending if the frame is already visible. If the frame is already visible by default then change the debounce value to true so it starts open and closes.