a person gave me this wonderful script (couldnt have done it with out ya) but i can't figure out how to make it have multiple dialogs in one. (multiple sentences in one chat) and it also stays on screen forever, it needs to fade after a small time. how can i achieve these things?
this is the script inside the textlabel
local RS = game:GetService("ReplicatedStorage") local Dialogue = RS:WaitForChild("Dialogue") local Waits = { "!", ".", "?", ";", ":", "," } local TextLabel = script.Parent function setText(Text) for i = 1, #Text do TextLabel.Text = string.sub(Text, 1, i) for Index, Breakers in pairs(Waits) do if string.sub(TextLabel.Text, i, i) == Breakers then task.wait(0.2) end end task.wait(0.1) end end Dialogue.OnClientEvent:Connect(function(msg) TextLabel.Parent.Parent.Enabled = true setText(msg) end)
this is the script inside the proximityprompt
local RS = game:GetService("ReplicatedStorage") local DialogueEvent = RS:WaitForChild("Dialogue") local Prox = script.Parent Prox.Triggered:Connect(function(plr) DialogueEvent:FireClient(plr, "hey there, want some snacks") end)
also, it has a remoteevent in replicated storage
You can use a table with the strings in it. And you can set up a new number variable.
local RS = game:GetService("ReplicatedStorage") local Dialogue = RS:WaitForChild("Dialogue") local Waits = { "!", ".", "?", ";", ":", "," } local TextLabel = script.Parent local DialogueTables = { "Hey there! I am the first dialogue to be shown!", "And I'm second!" } local Speed function setText(Text) for i = 1, #Text do Speed = (#Text * 0.1) TextLabel.Text = string.sub(Text, 1, i) for Index, Breakers in pairs(Waits) do if string.sub(TextLabel.Text, i, i) == Breakers then task.wait(0.2) end end task.wait(0.1) end end Dialogue.OnClientEvent:Connect(function() TextLabel.Parent.Parent.Enabled = true setText(DialogueTables[1]) task.wait(tonumber(Speed + 1)) -- Using tonumber() to make sure it's a number, and adding a 1 is to make sure it doesn't pop off and move onto the next sentence immediately, which might be annoying if you haven't finished reading it setText(DialogueTables[2]) task.wait(tonumber(Speed + 1)) TextLabel.Parent.Parent.Enabled = false end)
Of course, there MIGHT be some flaws in this script. If there is, please let me know and I'll try to improve!