Help with making skippable dialog

I’m currently trying to make a tutorial for my game. But I want a way to be able to skip through text. I’m not sure how since I don’t mess with inputservice to much.

I also would want to have players be able to press enter to skip

local function typewrite(textlabel,text)
	for i = 1,#text do
		script.Parent.TextLabel.Text = string.sub(text,1,i)
		script.Parent.Sound:Play()

		wait(.05)
	end
end

typewrite(script.Parent.TextLabel, "help")

This is what I have for a script. I found it in one of my old games and I believe it’s from an alvinblox tutorial.

1 Like

You could check if the player skips at all throughout the typewrite. I don’t really know how to explain so I’ll try to write some code.

local IS = game:GetService("UserInputService")

local skip = false

IS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        skip = true
    elseif input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.Return then
            skip = true
        end
    end
end)

local function typewrite(label, text)
    for i = 1, #text do
        script.Parent.TextLabel.Text = string.sub(text, 1, i)
        script.Parent.Sound:Play()

        if skip then break end

        wait(0.05)
    end

    label.Text = text
    skip = false
end
1 Like