I made a text script for dialogue, It works perfectly but the only problem is when its finished it has a debounce i never specified which is extremely long i dont understand why it does so can you guys help me understand? here is the starting script
script.Parent.Touched:Connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then plr:WaitForChild("PlayerGui").Text.Enabled = true local msg = "Howdy folks" local text = msg local Texty = plr:WaitForChild("PlayerGui").Text.TextLabel for i = 1,#text do Texty.Text = string.sub(text,1,i) local cor = coroutine.wrap(function() local sound = Instance.new("Sound") sound.Volume = .5 sound.SoundId = "rbxassetid://151715959" sound.Parent = plr:WaitForChild("PlayerGui").ScreenGui sound:Play() sound.Ended:Wait() sound:Destroy() end) cor() wait(0.03) end wait (3) plr:WaitForChild("PlayerGui").ScreenGui.Enabled = true end end)
Here is the script that handles the real dialogue and u talking also
local line = script.Parent.Value.Value script.Parent.MouseButton1Click:Connect(function() if line == 1 then script.Parent.Parent.Enabled = false local msg = "This is a test" local text = msg local plr = game.Players.LocalPlayer local Texty = script.Parent.Parent.Parent.Text.TextLabel Texty.Parent.Enabled = true for i = 1,#text do Texty.Text = string.sub(text,1,i) local cor = coroutine.wrap(function() local sound = Instance.new("Sound") sound.Volume = .5 sound.SoundId = "rbxassetid://151715959" sound.Parent = script.Parent.Parent sound:Play() sound.Ended:Wait() sound:Destroy() end) cor() wait(0.03) end wait (3) script.Parent.Parent.Enabled = true script.Parent.Text = "Want more?" line = 2 elseif line == 2 then script.Parent.Parent.Enabled = false local msg = "Idk im broke" local text = msg local plr = game.Players.LocalPlayer local Texty = script.Parent.Parent.Parent.Text.TextLabel Texty.Parent.Enabled = true for i = 1,#text do Texty.Text = string.sub(text,1,i) local cor = coroutine.wrap(function() local sound = Instance.new("Sound") sound.Volume = .5 sound.SoundId = "rbxassetid://151715959" sound.Parent = script.Parent.Parent sound:Play() sound.Ended:Wait() sound:Destroy() end) cor() wait(0.03) end wait (3) script.Parent.Parent.Enabled = false script.Parent.Parent.Parent.Text.Enabled = false line = 1 end end)
i would appreciate it alot if u take ur time to read this and help me thanks