I've created a script that commands a dialog box to appear and show text. It works fine, but when it's executed by this portion of the script, the dialog portion keeps repeating.
Basically, when a portion of the script says {"Bluh.","Bluh..."}, the dialog recieves it, but somehow, it repeats itself around the
player.PlayerGui.Bar.Dialog.Changed:connect(function()
if player.PlayerGui.Bar.Dialog.Visible == false then
player.PlayerGui.Bar.HP.Meter:TweenSize(UDim2.new(1,0,1,0), "Out", "Quad", 0.5,false)
player.PlayerGui.Bar.Dialog.Talk:Fire({"There you go!","When your health hits to zero,","it means you've been defeated!"},"Nothing",1.3)
player.PlayerGui.Bar.Dialog.Changed:connect(function()
if player.PlayerGui.Bar.Dialog.Visible == false then
script.Parent.PlayerTurn.Disabled = false
script.Parent.Turn.Value = true
end
end)
end
part.
Execution script:
script.Parent.Loss.Event:connect(function() -- If the player loses in the tutorial
local pl = script.Parent.PlayerInIt.Value
local player = game.Players:FindFirstChild(pl)
player.PlayerGui.Bar.Dialog.Talk:Fire({"Oh no!","Your health bar has been emptied!"},"Nothing",1.3)
player.PlayerGui.Bar.Dialog.Changed:connect(function()
if player.PlayerGui.Bar.Dialog.Visible == false then
player.PlayerGui.Bar.HP.Meter:TweenSize(UDim2.new(1,0,1,0), "Out", "Quad", 0.5,false)
player.PlayerGui.Bar.Dialog.Talk:Fire({"There you go!","When your health hits to zero,","it means you've been defeated!"},"Nothing",1.3)
player.PlayerGui.Bar.Dialog.Changed:connect(function()
if player.PlayerGui.Bar.Dialog.Visible == false then
script.Parent.PlayerTurn.Disabled = false
script.Parent.Turn.Value = true
end
end)
end
end)
end)
Dialog script
else if text[2] ~= nil then
script.Parent.Sound.Pitch = pitch
local text_length = string.len(text[index])
local text_instance = script.Parent.Health
player.Character.Humanoid.WalkSpeed = 0
for i = 1, text_length do
if i > text_length then break end
text_instance.Text = (string.sub(text[index],1,i))
textvalue = textvalue+1
script.Parent.Sound:Play()
wait(0.025)
end
script.Parent.Next.Visible = true
index = index+1
script.Parent.Next.MouseButton1Click:connect(function()
local db = true
text_length2 = string.len(text[index])
text_instance2 = script.Parent.Health
script.Parent.Next.Visible = false
if db == true then
db = false
print(text[index])
for i = 1, text_length2 do
if i > text_length2 then break end
text_instance2.Text = (string.sub(text[index],1,i))
textvalue = textvalue+1
script.Parent.Sound:Play()
wait(0.025)
end
end
index = index+1
script.Parent.Next.Visible = true
db = true
if text[index] == nil then
script.Parent.Next.Visible = false
script.Parent.Exit.Visible = true
script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 15
end
end)
end
