hi so i made a dialogue script and when it ends, the sound keeps playing so it doesnt “truly end”. how would i make it
local map = game.Workspace:WaitForChild('maps'):WaitForChild('RobloxPyramids')
local npc = map:WaitForChild('Simon')
local prox = npc:WaitForChild("ProximityPrompt")
local thetext = require(script:WaitForChild('ModuleScript'))
local uis = game:GetService('UserInputService')
prox.Triggered:Connect(function(plr)
plr.Character.Humanoid.WalkSpeed = 0
plr.Character.Humanoid.JumpHeight = 0
prox.Enabled = false
local ui = plr.PlayerGui
local dialogue = ui.dialogue
dialogue.Enabled = true
local count = 1
local TextLabel = dialogue.Text
local name = dialogue.PersonName
name.Text = 'simon'
local function typewriter()
TextLabel.Text = ''
script.Sound:Play()
for i = 1, #thetext[count] do
TextLabel.Text = string.sub(thetext[count], 1, i)
wait(0.05)
end
script.Sound:Stop()
end
typewriter()
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
count += 1
if thetext[count] then
typewriter()
else
count = 0
dialogue.Enabled = false
prox.Enabled = true
plr.Character.Humanoid.WalkSpeed = 16
plr.Character.Humanoid.JumpHeight = 7.2
-- there are no more lines left for simon to say so the dialogue should end... right?
end
end
end)
end)
if my explication was not clear enough please lmk
thank you ![]()