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

13 comments

0

if u need any more information tell me and ill give it

0

What you mean by "bounce"? Can you please explain it more

0

it means when i touch it the text works but then when i try touch it again i cant do it and i have to wait like 100 seconds to do it again

0

missing end for for loop at line 37 ?

0

i put the ends at the end of the script

0

but there should be a end there, or the loop is supposed to run all the rest of the script?

0

it works like this, first button pres text loop appears then it ends then 2nd button press then etc

0

hello?

0

are those lines supposed to run #lines times?

0

can you join website chat? its easyer to talk

0

??

0

wut is website talk?

0

fix your indentation