I am currently wanting to make a custom made GUI dialogue system within my game and officially got one sentence of dialogue working. But when I try putting in more dialogue, it stops working.
Another thing I’m trying to do is so the script will work through one text label, and not through many frames to cause as least lag as possible. I would know how to do this with many frames, but I want to do it with one text label.
Here is the script I currently have:
I would really appreciate any help of how to fix this because I have found no tutorial or any script that can show how to make it in the way I want to make it.
1 Like
Your approach of iterating through text isn’t exactly the way it should be done. Your method of doing so will just fire both of those functions at the same time, causing unintended behavior to occur.
You should store the dialogue in an array and iterate through it like so:
local dialogue = {"Dialogue1", "NextDialogue", ... }
local function displayText(text)
script.Parent.Parent.TextPart.Text = text
end
local dialogueInSession = false -- prevent any issues with the event firing more than it needs to
local mouseButtonConnection; -- Just in case we need to disconnect
mouseButtonConnection = script.Parent.MouseButton1Click:Connect(function()
if dialogueInSession then return end -- guard clause
dialogueInSession = true
for _, text in ipairs(dialogue) do
displayText(text)
script.Parent.MouseButton1Click:Wait() -- condition for advancing, change based on needs
end
dialogueInSession = false
end)
Please note that this is a very quick mock-up design of such a system, and should be adjusted to your needs.
1 Like