Alright so i have this script
local progressionConnection
local dialogueConnection
local event = game.ReplicatedStorage.GiveObjective
local player
local testDialogue = {
{
command = "Dialogue",
DialogueText = "Hello"
},
{
command = "Prompt",
DialogueText = "Now you can choose",
option1 = {
text = "SayCat",
followup = {
{
command = "Dialogue",
DialogueText = "It works cat"
},
{
command = "Prompt",
DialogueText = "Another thing for the cat",
option1 = {
text = "First option",
followup = {
{
command = "Prompt",
DialogueText = "cat final question",
option1 = {
text = "Monkey",
},
option2 = {
text = "Gorilla"
}
}
}
},
option2 = {
text = "Second option",
followup = {
{
command = "Dialogue",
DialogueText = "cat123"
},
{
command = "Dialogue",
DialogueText = "cat1234"
},
{
command = "Dialogue",
DialogueText = "cat12345"
},
}
}
},
}
},
option2 = {
text = "SayDog",
followup = {
{
command = "Dialogue",
DialogueText = "It works dog"
}
}
},
},
}
local dialogueIndex = 1
function Ui(plr, tableToUse, current)
if not tableToUse[current] then return end
print(tableToUse[1])
local textLabel = plr.PlayerGui.Conversations.Frame.TextLabel
local choice1 = textLabel.Parent.Choice1
local choice2 = textLabel.Parent.Choice2
-- Ensure the frame is visible
plr.PlayerGui.Conversations.Frame.Visible = true
if tableToUse[current].command == "Dialogue" then
-- Set dialogue text and show the 'Next' button
textLabel.Text = tableToUse[current].DialogueText
choice1.Visible = true
choice1.Text = "Next"
choice2.Visible = false -- Hide the second choice
-- Reset previous connections to avoid multiple triggers
if dialogueConnection then dialogueConnection:Disconnect() end
dialogueIndex += 1
-- Connect the 'Next' button
dialogueConnection = choice1.MouseButton1Click:Connect(function()
Ui(plr, tableToUse, dialogueIndex)
end)
elseif tableToUse[current].command == "Prompt" then
-- Set prompt text and show both choices
textLabel.Text = tableToUse[current].DialogueText
choice1.Visible = true
choice2.Visible = true
choice1.Text = tableToUse[current].option1.text
choice2.Text = tableToUse[current].option2.text
-- Reset previous connections to avoid multiple triggers
if dialogueConnection then dialogueConnection:Disconnect() end
--if progressionConnection then progressionConnection:Disconnect() end
dialogueIndex += 1
-- Connect both choice buttons
dialogueConnection = choice1.MouseButton1Click:Connect(function()
dialogueIndex = 1
progressionConnection:Disconnect()
Ui(plr, tableToUse[current].option1.followup, 1)
end)
progressionConnection = choice2.MouseButton1Click:Connect(function()
dialogueIndex = 1
progressionConnection:Disconnect()
Ui(plr, tableToUse[current].option2.followup, 1)
end)
end
end
game.Players.PlayerAdded:Connect(function(plr)
task.wait(2)
player = plr
Ui(plr, testDialogue, 1)
end)
--[[function entertedRestaurant()
progressionConnection = game.Workspace.MainDoor.PromptPart.ProximityPrompt.Triggered:Connect(function()
progressionConnection:Disconnect()
event:FireClient(player, "empty", "hide")
task.wait(2)
event:FireClient(player, "Go to the staff room and clock in", "show")
end)
end
--]]
seeing it you probably immediately thought: “What is that massive table” and thats the issue i want to address. the script works as intended. However that table is just so ugly to look at and i know it will by a nightmare to modify to it, anyways is there a better way to do this, somehow avoiding that massive table? For now its just for testing and hasn’t further been implemented into the game so now is the best time to change it if need be