My dialogue UI keeps repeating itself when it was suppose to end. What do I do?
Here’s what meant by “constantly repeating”:
Module:
local dialogueHandler = {}
function dialogueHandler.TypeWriter(object, text, pause)
object.Text = " "
for i, v in pairs(text) do
for i = 1, string.len(v) do wait(0.05)
object.Text = string.sub(v, 1, i)
end
wait(string.len(v) / 20)
end
end
function dialogueHandler.DisableOptions(button1, button2, button3, button4)
button1.Visible = false
button2.Visible = false
button3.Visible = false
button4.Visible = false
end
function dialogueHandler.OptionLabeling(button1, text1, button2, text2, button3, text3, button4, text4)
button1.Text = text1
button2.Text = text2
button3.Text = text3
button4.Text = text4
button1.Visible = true
button2.Visible = true
button3.Visible = true
button4.Visible = true
end
return dialogueHandler
Script placed in a proximity prompt:
local prompt = script.Parent
local dialogueHandler = require(game.ReplicatedStorage:WaitForChild("DialogueHandler"))
local text = {
"hidddddddddddddddddddddddddddddddddddd",
"this is my house",
"now leave me be"
}
local text2 = {
"nu uh",
"my lawyer advised not to finish this joke"
}
prompt.PromptButtonHoldBegan:Connect(function(player)
highlight = Instance.new("Highlight")
highlight.FillTransparency = 1
highlight.OutlineColor = Color3.new(255, 255, 255)
highlight.Adornee = prompt.Parent
highlight.DepthMode = Enum.HighlightDepthMode.Occluded
highlight.Parent = prompt.Parent
end)
prompt.PromptButtonHoldEnded:Connect(function(player)
highlight:Destroy()
end)
prompt.Triggered:Connect(function(player)
local screenGUI = player.PlayerGui:WaitForChild("Dialogue")
screenGUI.Enabled = true
local dialogue = screenGUI:WaitForChild("DialogueText")
local option1 = screenGUI.Option1
local option2 = screenGUI.Option2
local option3 = screenGUI.Option3
local option4 = screenGUI.Option4
dialogueHandler.DisableOptions(option1, option2, option3, option4)
dialogueHandler.TypeWriter(dialogue, text, .01)
dialogueHandler.OptionLabeling(option1, "my lawyer advised not to finish this joke", option2, "nuh uh", option3, "whar", option4, "...")
option1.MouseButton1Click:Connect(function()
dialogueHandler.DisableOptions(option1, option2, option3, option4)
dialogueHandler.TypeWriter(dialogue, text2, .01)
option1.Visible = true
option1.Text = "..."
end)
end)