ProximityPrompt has to be activated twice; works fine after?

Hi, I’m trying to use proximity prompts for text overlays and they work but only after I have activated them twice. After I press it twice it works fine and even with multiples I have to activate them all twice for it to work as intended with just a single press.

I’m using a remote event to write into the textbox. Here is the code for the proximity prompt

local replicatedStorage = game.ReplicatedStorage

local remoteEvent = replicatedStorage.RemoteVolt

local ProximityPrompt = script.Parent

local function onPromptTriggered(player)

script.Parent.Triggered:Connect(function(playerWhoTriggered)

remoteEvent:FireClient(playerWhoTriggered)

end)

end

ProximityPrompt.Triggered:Connect(onPromptTriggered)

and the local script in the GUI

local replicatedStorage = game.ReplicatedStorage
local remoteEvent = replicatedStorage.RemoteVolt
local specificPrompt = game.Workspace.Block.ProximityPrompt
remoteEvent.OnClientEvent:Connect(function()
script.Parent.TextLabel.Visible = true
local function typewrite (textlabel, text)
for i = 1, text do
textlabel.Text = string.sub(text, 1, i)
wait(.05)
end
end
typewrite(script.Parent.TextLabel,“line1”,0.05)
wait(1)
typewrite(script.Parent.TextLabel,“line2”,0.05)
wait(3)
typewrite(script.Parent.TextLabel," ",0.3)
script.Parent.TextLabel.Visible = false
end)

as well as the map file I created to troubleshoot
proxprompt.rbxl (42.8 KB)

This is because after you fire the triggered event, you’re waiting again for the triggered event.
Change the onPromptTriggered function to this:

local function onPromptTriggered(player)
   remoteEvent:FireClient(player)
end
1 Like

huh… simple oversight always seems to make the most time consuming problems. thanks for the quick reply.

1 Like