ProximityPrompt only works once

Hi! So I have a proximity prompt that when triggered, causes a gui to have an animation with this script:

local decal = script.Parent.Parent.Parent:FindFirstChildOfClass('Decal')
local part = script.Parent.Parent.Parent

local on = false

script.Parent.Triggered:Connect(function(plr)
	local skips = plr.leaderstats.Skips
	local gui = plr.PlayerGui.SkipsShop.ImageLabel
	print("huh")
	
	if skips.Value >= 1 then
		print("working")
		part.CanCollide = false 
		part.Transparency = 0.7 
		decal.Transparency = 0.7
		local newvalue = skips.Value - 1
		skips.Value = newvalue
		wait(4)
		part.CanCollide = true 
		part.Transparency = 0
		decal.Transparency = 0
		
	elseif skips.Value < 1 then
		print("played")
		gui.Visible = true
		gui:TweenPosition(UDim2.new(0.342, 0,0.239, 0), "Out","Bounce",1)
	
	end
	

	
		
			
			
		
		

end)

Then, when the player wants to close it, they click the x button on the gui with this script:

local player = game.Players.LocalPlayer

local gui = player.PlayerGui.SkipsShop.ImageLabel
local button = gui.XButton
button.MouseButton1Click:Connect(function()
	print("closing")
	gui.Visible = false
	gui:TweenPosition(UDim2.new(-0.313, 0,0.239, 0), "Out","Bounce",1)
end)

But for some reason, after you use the proximity prompt and close the gui, it will not work again.
Note: Before you respond, read this: There are no errors. The second time I use the proximity prompt, the print statement located here:

	elseif skips.Value < 1 then
		print("played")

Is playing but the gui is not becoming visible and the position isn’t changing. What can I do?

1 Like

Have you tried walking completely away from the MaxActivationDistance distance and reentering the ProximityPrompt radius?

I’d also like to see your prompt’s properties.

try this Proximity Prompt only works once then no longer triggers

Is the script in the GUI a local script and the script in the proximity prompt a server script. If that’s the case try changing them to the same kind of script.

This doesn’t do anything. Here are the properties:
image

Uncheck RequiresLineOfSight and retest.
EDIT: Waiting for your response!

This post doesn’t help me because there are no solutions.

I changed the proximityprompt script to a local script and it no longer works. I can’t change the xbutton script to a serverscript because I can’t define player. It just gives me attempt to index nil with player or something

Doesn’t work. I tried going away from it too.

Look, there’s a lot of information you’re not giving me now that I’m reading your newer posts. Your Proximity Prompt trigger code should be in a LocalScript considering its manipulating GUIs. It should’ve never been in a regular Script.

And copying code over scripts isn’t something you can just do and expect it to work.
You have to refactor some parts because the local script and server environments are different. I can explain to you how in a sec.

Sigh, show me all your scripts in their current states.

I change it when I convert it to a local script. Here is what I use for the proximityprompt in a local script that isn’t working:

local decal = script.Parent.Parent.Parent:FindFirstChildOfClass('Decal')
local part = script.Parent.Parent.Parent
local plr = game.Players.LocalPlayer
local on = false

script.Parent.Triggered:Connect(function()
	local skips = plr.leaderstats.Skips
	local gui = plr.PlayerGui.SkipsShop.ImageLabel
	print("huh")

	if skips.Value >= 1 then
		print("working")
		part.CanCollide = false 
		part.Transparency = 0.7 
		decal.Transparency = 0.7
		local newvalue = skips.Value - 1
		skips.Value = newvalue
		wait(4)
		part.CanCollide = true 
		part.Transparency = 0
		decal.Transparency = 0

	elseif skips.Value < 1 then
		print("played")
		gui.Visible = true
		gui:TweenPosition(UDim2.new(0.342, 0,0.239, 0), "Out","Bounce",1)

	end









end)

Tell me what you mean by not working. Is skips.Value ever greater than 1? Less than 1? What does your Output Window look like?

EDIT: I feel like you should rewrite this script from the ground up, it’s just really messy right now too. Start by using ProximityPrompt.Triggered on the server, but obviously don’t manipulate the GUIs there, but fire a RemoteEvent to the client and then do your GUI work there. You’d use FireClient and OnClientEvent.

There are no errors. Skips.Value is always less than 1 when I test it so this should always be triggering:

elseif skips.Value < 1 then
		print("played")
		gui.Visible = true
		gui:TweenPosition(UDim2.new(0.342, 0,0.239, 0), "Out","Bounce",1)

	end

I need to see your Output Window, Rome. Take a screenshot.

There is nothing of relevance:
image

The serverscriptservice error has nothing to do with it.

Is your Output window scrolled up all the way to the top where you can see relevant information? Trust me, this is common. Or it might be the other way around, where you have to scroll down.

Your prints has to be coming when you trigger the prompt. I hope you’re triggering the prompt in your tests with RequiresLineOfSight off.

Back to topic, your prints has to be showing up somewhere. Scroll through the output and show me somethin’.

I’m talking about your prints: "huh", "working", etc. Any and all of them. Even if they show only for 1 time, I still need to see.

When I changed it to a local script, it is no longer triggering which means it is not printing anything.

Here is everything, as you can see, no print statements:
image