Prompt.Triggered doesn't work

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix my problem with Prompt.Triggered

  2. What is the issue? Include screenshots / videos if possible!
    I don’t understand what’s the issue. There are no errors.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find any solutions for that.

-- Services
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local MarketPlaceService = game:GetService("MarketplaceService")

-- Player
local Player = Players.LocalPlayer
local Char = Player.CharacterAdded:Wait() or Player.Character

-- Passport Dialogue Frame
local PassportDialogueFrame = script.Parent.PassportDialogue

-- Passport Dialogue Buttons
local PassportDialogueButtons = {PassportDialogueFrame.AcceptButton, PassportDialogueFrame.DeclineButton}

-- Click Sound
local ClickSound = script.Parent.ClickSound

-- Select Sound
local SelectSound = script.Parent.SelectSound

-- Prompt 
local Prompt = workspace.PassportGiverHitbox.ProximityPrompt

-- Tool
local Tool = script.Parent.Passport

local Question = "Would you like to get a passport?"
local Say2 = "Here you go..."
local Say3 = "Okay, bye..."
local QuestionLabel = PassportDialogueFrame.Question

for _,Button in ipairs(PassportDialogueButtons) do
    if not Button:IsA("TextButton") then continue end
    local UICorner = Button:WaitForChild("UICorner")
    local Square = TweenService:Create(UICorner,TweenInfo.new(0.1),{CornerRadius = UDim.new(0.05,0)})
    local Circle = TweenService:Create(UICorner,TweenInfo.new(0.1),{CornerRadius = UDim.new(0.5,0)})
    Circle:Play()
    Button.MouseEnter:Connect(function()
        if SelectSound.SoundId ~= nil then
            SelectSound:Play()
        end
        Button.UIStroke.Enabled = true
        Square:Play()
    end)
    Button.MouseLeave:Connect(function()
        Button.UIStroke.Enabled = false
        Circle:Play()
    end)
    Button.MouseButton1Click:Connect(function()
        if ClickSound.SoundId ~= nil then
            ClickSound:Play()
        end
    end)
end

Prompt.Triggered:Connect(function()
    PassportDialogueFrame.Visible = true
   
    for i = 1, #Question do
        QuestionLabel.Text = string.sub(Question, 1, i)
    end
    repeat wait() until QuestionLabel.Text == Question
    PassportDialogueFrame.AcceptButton.Visible = true
    PassportDialogueFrame.DeclineButton.Visible = true
end)

PassportDialogueFrame.AcceptButton.MouseButton1Click:Connect(function()
    if Player.Backpack:FindFirstChild("Passport") or Char:FindFirstChild("Passport") then
        return
    else
        local NewTool = Tool:Clone()
        NewTool.Parent = Player.Backpack
        for i = 1, #Question do
            QuestionLabel.Text = string.sub(Say3, 1, i)
        end
    end
    
    repeat wait() until QuestionLabel.Text == Say2
    PassportDialogueFrame.Visible = false
    PassportDialogueFrame.AcceptButton.Visible = false
    PassportDialogueFrame.DeclineButton.Visible = false
end)

PassportDialogueFrame.DeclineButton.MouseButton1Click:Connect(function()
    for i = 1, #Question do
        QuestionLabel.Text = string.sub(Say3, 1, i)
    end
    repeat wait() until QuestionLabel.Text == Say3
    PassportDialogueFrame.Visible = false
    PassportDialogueFrame.AcceptButton.Visible = false
    PassportDialogueFrame.DeclineButton.Visible = false
end)

1 Like

Try using a print in the event and see if that works. Does PassportDialogueFrame become visible?

1 Like

It didn’t print.
image

1 Like

While testing, check if the ProximityPrompt is actually there. Let me know about results!

Where is the script located? Do other things work?

1 Like


There is…

Yeah, other things work. In starter gui.

Could you show us your Explorer? Like, show us the workspace where your ProximityPrompt is and other necessary things.

Workspace:
image
StarterGui:
image

Alright. Try these things:

  1. Put a print before connecting Triggered.
  2. Check if there are multiple parts called PassportGiverHitbox.

Let me know about results!

There aren’t any other parts for the proximity prompt.
image
And doesn’t print.

If it doesn’t print, then it’s most likely a different problem than we think. This means that the code before either errors or yields (delays) the code. My guess is that

local UICorner = Button:WaitForChild("UICorner")

is causing an infinite yield and thus not allow your code to continue. Can you confirm?

There’s no infinite yield… What happens if I put the functions first?

Defining functions earlier doesn’t make a difference. The problem here is that the script is not reaching the part where you connect your .Triggered. What you could try doing is connecting before the for-loop and see if that makes a difference:

-- Services
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local MarketPlaceService = game:GetService("MarketplaceService")

-- Player
local Player = Players.LocalPlayer
local Char = Player.CharacterAdded:Wait() or Player.Character

-- Passport Dialogue Frame
local PassportDialogueFrame = script.Parent.PassportDialogue

-- Passport Dialogue Buttons
local PassportDialogueButtons = {PassportDialogueFrame.AcceptButton, PassportDialogueFrame.DeclineButton}

-- Click Sound
local ClickSound = script.Parent.ClickSound

-- Select Sound
local SelectSound = script.Parent.SelectSound

-- Prompt 
local Prompt = workspace.PassportGiverHitbox.ProximityPrompt

-- Tool
local Tool = script.Parent.Passport

local Question = "Would you like to get a passport?"
local Say2 = "Here you go..."
local Say3 = "Okay, bye..."
local QuestionLabel = PassportDialogueFrame.Question

Prompt.Triggered:Connect(function()
    PassportDialogueFrame.Visible = true
   
    for i = 1, #Question do
        QuestionLabel.Text = string.sub(Question, 1, i)
    end
    repeat wait() until QuestionLabel.Text == Question
    PassportDialogueFrame.AcceptButton.Visible = true
    PassportDialogueFrame.DeclineButton.Visible = true
end)

PassportDialogueFrame.AcceptButton.MouseButton1Click:Connect(function()
    if Player.Backpack:FindFirstChild("Passport") or Char:FindFirstChild("Passport") then
        return
    else
        local NewTool = Tool:Clone()
        NewTool.Parent = Player.Backpack
        for i = 1, #Question do
            QuestionLabel.Text = string.sub(Say3, 1, i)
        end
    end
    
    repeat wait() until QuestionLabel.Text == Say2
    PassportDialogueFrame.Visible = false
    PassportDialogueFrame.AcceptButton.Visible = false
    PassportDialogueFrame.DeclineButton.Visible = false
end)

PassportDialogueFrame.DeclineButton.MouseButton1Click:Connect(function()
    for i = 1, #Question do
        QuestionLabel.Text = string.sub(Say3, 1, i)
    end
    repeat wait() until QuestionLabel.Text == Say3
    PassportDialogueFrame.Visible = false
    PassportDialogueFrame.AcceptButton.Visible = false
    PassportDialogueFrame.DeclineButton.Visible = false
end)

for _,Button in ipairs(PassportDialogueButtons) do
    if not Button:IsA("TextButton") then continue end
    local UICorner = Button:WaitForChild("UICorner")
    local Square = TweenService:Create(UICorner,TweenInfo.new(0.1),{CornerRadius = UDim.new(0.05,0)})
    local Circle = TweenService:Create(UICorner,TweenInfo.new(0.1),{CornerRadius = UDim.new(0.5,0)})
    Circle:Play()
    Button.MouseEnter:Connect(function()
        if SelectSound.SoundId ~= nil then
            SelectSound:Play()
        end
        Button.UIStroke.Enabled = true
        Square:Play()
    end)
    Button.MouseLeave:Connect(function()
        Button.UIStroke.Enabled = false
        Circle:Play()
    end)
    Button.MouseButton1Click:Connect(function()
        if ClickSound.SoundId ~= nil then
            ClickSound:Play()
        end
    end)
end

Again, didn’t work. I’ve put your script.

Could you at least give me more information? Like, show the output. It’s either the script doesn’t run at all or your script errors or warns.

Here’s the output:
image

I am genuinely confused lol. Could you send a copy of your studio file in DM’s or here? I’ll try to figure it out from there.

1 Like

Well, I will only send proximity prompt system because it is not my game. I’m a developer of it.

One thing I noticed is this:
image

I’m not sure if you are aware, but it’s the other way around. Maybe that’s the fix.