Proximity Prompt only activates Once

Hello.

I have been having an issue every time I use proximity prompts, for some reason they only work once then they stop responding completely.

I have tried remove certain parts of the script but it never works, there’s nothing online for it either.

Here is the test I did, the prints seemed to only work once because it only activated once.

My script:

local model = script.Parent.Parent.Parent
local teleports = workspace.Teleport
local loc = teleports.Showcase
local values = model.Values

local proximityPrompt = script.Parent

local isTouched = false

print("Locals")

proximityPrompt.Triggered:Connect(function(player)
	
	print("Activation")
	
	local char = player.Character
	
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	
	print("Humanoid")
	
	if humanoid then
		if not isTouched then
			isTouched = true
	
			print("Debounce")
	
	local gui = player.PlayerGui.Frame
	local frame = gui.Frame
	local loca = frame.Location
	local label = frame.Label
	local text = frame.Text
	local gif = frame.GIF
	
	for i = 1,10 do
		loca.Text = loc.Name
		frame.BackgroundTransparency -= 0.1
		gif.ImageTransparency -= 0.1
		loca.TextTransparency -= 0.1
		label.TextTransparency -= 0.1
		text.TextTransparency -= 0.1
		loca.UIStroke.Transparency -= 0.1
		label.UIStroke.Transparency -= 0.1
		text.UIStroke.Transparency -= 0.1
		wait(0.000001)
			end
			
			print("Gui Load")

	player.Character.HumanoidRootPart.Position = loc.Position

	wait(2)

	for i = 1,10 do
		frame.BackgroundTransparency += 0.1
		gif.ImageTransparency += 0.1
		loca.TextTransparency += 0.1
		label.TextTransparency += 0.1
		text.TextTransparency += 0.1
		loca.UIStroke.Transparency += 0.1
		label.UIStroke.Transparency += 0.1
		text.UIStroke.Transparency += 0.1
				wait(0.000001)
			end
			
			print("Gui Delete")
			
			wait(2)
			isTouched = false
			
			print("Debounce Again")
			
		end
	end
	print("End")
end)

If you know what the issue is please get back to me, thank you.

3 Likes
2 Likes

I just changed my script to this article but i’m still having the same issue every time, it works but then it stops working after one time, do you know why?

local model = workspace.Portal
local teleports = workspace.Teleport
local loc = teleports.Showcase
local values = model.Values

local proximityPrompt = script.Parent

local isTouched = false

local RunService = game:GetService("RunService")

local ObjectActions = {}

function ObjectActions.promptTriggeredActions(promptObject, player)
	local ancestorModel = promptObject:FindFirstAncestorWhichIsA("Model")
	local valueFolder = ancestorModel:FindFirstChild("Values")
	local soundFolder = ancestorModel:FindFirstChild("Sounds")
	
	local char = player.Character

	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	
	if humanoid then
		if not isTouched then
			isTouched = true


	if ancestorModel.Name == "Portal" then

				local gui = player.PlayerGui.Frame
				local frame = gui.Frame
				local loca = frame.Location
				local label = frame.Label
				local text = frame.Text
				local gif = frame.GIF

				for i = 1,10 do
					loca.Text = loc.Name
					frame.BackgroundTransparency -= 0.1
					gif.ImageTransparency -= 0.1
					loca.TextTransparency -= 0.1
					label.TextTransparency -= 0.1
					text.TextTransparency -= 0.1
					loca.UIStroke.Transparency -= 0.1
					label.UIStroke.Transparency -= 0.1
					text.UIStroke.Transparency -= 0.1
					wait(0.000001)
				end

				player.Character.HumanoidRootPart.Position = loc.Position

				wait(2)

				for i = 1,10 do
					frame.BackgroundTransparency += 0.1
					gif.ImageTransparency += 0.1
					loca.TextTransparency += 0.1
					label.TextTransparency += 0.1
					text.TextTransparency += 0.1
					loca.UIStroke.Transparency += 0.1
					label.UIStroke.Transparency += 0.1
					text.UIStroke.Transparency += 0.1
					wait(0.000001)
				end

				wait(2)
				isTouched = false
			end
		end
	end
end

return ObjectActions
4 Likes

Let me take a look. Give me a moment.

2 Likes

Change the function into a local function.

And then declare the function at the end of the script.

Make sure that the proximity prompt’s parent is NOT a model, but a part.

2 Likes
local model = script.Parent.Parent.Parent
local teleports = workspace:WaitForChild("Teleport")
local loc = teleports:WaitForChild("Showcase")
local values = model:WaitForChild("Values")
local proximityPrompt = script.Parent
local isTouched = false

proximityPrompt.Triggered:Connect(function(player)
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	local hmr = character:WaitForChild("HumanoidRootPart")
	if humanoid then
		if not isTouched then
			isTouched = true
			local gui = player:WaitForChild("PlayerGui")
			local frame = gui:WaitForChild("Frame")
			local location = frame:WaitForChild("Location")
			local label = frame:WaitForChild("Label")
			local text = frame:WaitForChild("Text")
			local gif = frame:WaitForChild("GIF")
			for i = 1, 10 do
				location.Text = loc.Name
				frame.BackgroundTransparency -= 0.1
				gif.ImageTransparency -= 0.1
				location.TextTransparency -= 0.1
				label.TextTransparency -= 0.1
				text.TextTransparency -= 0.1
				location.UIStroke.Transparency -= 0.1
				label.UIStroke.Transparency -= 0.1
				text.UIStroke.Transparency -= 0.1
				task.wait()
			end
			hmr.Position = loc.Position
			task.wait(2)
			for i = 1, 10 do
				frame.BackgroundTransparency += 0.1
				gif.ImageTransparency += 0.1
				location.TextTransparency += 0.1
				label.TextTransparency += 0.1
				text.TextTransparency += 0.1
				location.UIStroke.Transparency += 0.1
				label.UIStroke.Transparency += 0.1
				text.UIStroke.Transparency += 0.1
				wait()
			end
			task.wait(2)
			isTouched = false
		end
	end
end)

I fixed the following (unless you meant for it to be a Frame inside of a Frame), the names seem wrong though “gui” & “frame”.

local gui = player.PlayerGui.Frame
local frame = gui.Frame

I’ve added waits to ensure everything that is requested by the script has loaded by the time the script executes, I’ve replaced wait() with task.wait() as it’s more optimised, on an additional note making calls like “wait(0.0000001)” isn’t necessary, the shortest length of time a wait() call can last for is 1/60th of a second which is “wait(0.01666)”, this is the default used when calling wait() without an argument.

1 Like

Try checking your script(s) and see if there is anything disabling the Prompt when it is triggered.

3 Likes