What do you want to achieve? Keep it simple and clear!
I want to fix my problem with Prompt.Triggered
What is the issue? Include screenshots / videos if possible!
I don’t understand what’s the issue. There are no errors.
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)
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?
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