I tested it ingame the options show up the first time the dialogue is created but upon pressing any option there is no new option created. I specifically checked the amount and there were still 3.
local function Dialogue(str, options, cooldown, name, skippable, optionsArray)
if LoadingScreen.Visible == true or PlayButton.Visible == true then
return
end
for i,v in pairs(Hud:GetChildren()) do
if v:IsA('GuiObject') then
v.Visible = false
end
end
if name ~= nil and type(name) == 'string' then
DialogueName.Text = name
end
DialogueFrame.Visible = true
DialogueFrame.Transparency = 0
if options then
for i = 1, #optionsArray do
local newOption = script:WaitForChild('Option'):Clone()
newOption.Parent = OptionsFrame
newOption.Text = optionsArray[i].Text
newOption.TextColor3 = optionsArray[i].Color
newOption:WaitForChild('UIStroke').Color = optionsArray[i].Color
newOption.MouseButton1Click:Connect(function()
print('Clicked')
if DialogueText.Text == str then
if optionsArray[i].Next ~= nil and optionsArray[i].Next ~= false then
Dialogue(
optionsArray[i].String,
optionsArray[i].Options,
optionsArray[i].Cooldown,
optionsArray[i].Name,
optionsArray[i].Skippable,
optionsArray[i].Array
)
elseif optionsArray[i].Next == nil or optionsArray[i].Next == false then
for i,v in pairs(OptionsFrame:GetChildren()) do
if v:IsA('GuiObject') then
v:Destroy()
end
end
print('not clicked')
Dialogue('You have reached the end of my dialogue', false, .1, '???', true, {})
end
end
end)
end
end
ClickText.Text = 'Click anywhere to skip.'
local Typing = true
task.spawn(function()
for i = 1, #str do
if Typing == true then
task.wait(cooldown)
DialogueText.Text = string.sub(str, 1, i)
elseif Typing == false then
DialogueText.Text = str
end
end
end)
if skippable then
mouse.Button1Down:Connect(function()
Typing = false
if ClickText.Text:lower() == 'click anywhere to close.' and not OptionsFrame:FindFirstChildWhichIsA('TextButton') then
DialogueFrame.Visible = false
for i,v in pairs(Hud:GetChildren()) do
if v:IsA('GuiObject') and not table.find(keepInvisible, v.Name) then
v.Visible = true
end
end
end
end)
end
task.spawn(function()
repeat task.wait() until DialogueText.Text == str
ClickText.Text = 'Click anywhere to close.'
end)
end
--optionsArray[i].String,
--optionsArray[i].Options,
--optionsArray[i].Cooldown,
--optionsArray[i].Name,
--optionsArray[i].Skippable,
--optionsArray[i].OptionsArray,
repeat task.wait( ) until PlayButton.Visible == false and LoadingScreen.Visible == false
Dialogue('Hello World. This is a dialogue test conducted by 112365595.', true, 0.1, '112365595', true,
{
{
['Text'] = 'Yes',
['Color'] = Color3.fromRGB(125, 255, 78),
['Next'] = true,
['String'] = 'Bringing up next dialogue',
['Cooldown'] = 0.1,
['Name'] = '???',
['Skippable'] = true,
['Options'] = true,
['Array'] = {
['Text'] = 'Yes',
['Color'] = Color3.fromRGB(125, 255, 78),
['Next'] = true,
['String'] = 'Bringing up next dialogue',
['Cooldown'] = 0.1,
['Name'] = '???',
['Skippable'] = true,
['Options'] = false,
['Array'] = nil,
},
},
{
['Text'] = 'No',
['Color'] = Color3.fromRGB(255, 58, 68),
['Next'] = false,
['String'] = 'Bringing up next dialogue',
['Cooldown'] = 0.1,
['Name'] = '???',
['Skippable'] = true,
['Options'] = false,
['Array'] = nil,
},
{
['Text'] = 'Test',
['Color'] = Color3.fromRGB(255, 58, 68),
['Next'] = true,
['String'] = 'Secret ending! Real lets goooooooooo!',
['Cooldown'] = 0.1,
['Name'] = '???',
['Skippable'] = true,
['Options'] = true,
['Array'] = {
['Text'] = 'Yes',
['Color'] = Color3.fromRGB(125, 255, 78),
['Next'] = true,
['String'] = 'Bringing up next dialogue',
['Cooldown'] = 0.1,
['Name'] = '???',
['Skippable'] = true,
['Options'] = false,
['Array'] = nil,
},
},
}
)