I’m trying to make branching dialogue with choices, and there’s one BindableEvent that handles giving new choices and dialogue to the GUI, and one BindableEvent that handles deleting the old, previous choices.
The problem is that when you choose an choice in the dialogue, it adds the new dialogue choices and deletes them at the same time, along with the previous options.
button.MouseButton1Click:Connect(function()
clearEvent:Fire() --Deletes all choice buttons in GUI
populateEvent:Fire(button.Dialogue) --Adds new choices
end)
local rep = game:GetService("ReplicatedStorage")
local parent = script.Parent
rep.Chat.ClearOptionsClient.Event:Connect(function()
local optionChildren = parent.OptionFrame:GetChildren()
for _, child in ipairs(optionChildren) do
if child:IsA("ImageButton") then
child:Destroy()
end
end
end)
--The clear event
I’ve tried placing a task.wait(0.1) after the clearEvent, but that doesn’t work either. I also tried combining these two events into one and just making the option clearing happen before the new options are added, but that still didn’t work. I just need some method to clear the options and only add the new options once the old ones are cleared. Any help is appreciated.