I am trying to make a KeyboardInput utility that will return the string inputted. But My issue is if you make a typo and press no (if Dialogue:PromptYesOrNo(IsCorrectPrompt) then
), then the script will continue instead of yielding until if Dialogue:PromptYesOrNo(IsCorrectPrompt) then
returns true. Help?
function Dialogue:KeyboardInput(Message, Placeholder, Finished)
if Dialogue.Enabled == false then
Dialogue.Enabled = true
Dialogue.BroadcastBox.Position = UDim2.new(0.0, 0.0, 1.0, 0.0)
Dialogue.BroadcastLabel.Text = ""
TweenBroadcastBoxIn:Play()
task.wait(1.0)
end
TypeWriteText({
Object = Dialogue.BroadcastLabel,
Text = Message,
SoundEnabled = true,
Time = Dialogue.Speed})
local InputBox = CreateObject "TextBox" {
BackgroundColor3 = Color3.new(0.0, 0.0, 0.0),
BorderSizePixel = 0.0,
BackgroundTransparency = 1.0,
ClearTextOnFocus = true,
Text = Placeholder,
TextColor3 = Color3.new(1.0, 1.0, 1.0),
TextScaled = true,
TextWrapped = true,
Font = Enum.Font.PatrickHand,
PlaceholderText = Placeholder,
Name = "InputBox",
Position = UDim2.new(0.25, 0.0, -1.0, 0.0),
Size = UDim2.new(0.5, 0.0, 0.3, 0.0),
ZIndex = 1.0, Parent = Gui,
CreateObject "UICorner" {
CornerRadius = UDim.new(0.1, 0.0)
},
CreateObject "UIStroke" {
Thickness = 2,
ApplyStrokeMode = "Border"
},
FocusLost = function(EnterPressed)
if EnterPressed then
if string.len(Gui:WaitForChild("InputBox").Text) >= 10 then
Dialogue.BroadcastLabel.Text = "Name too long!"
else
Blip:Play()
TweenService:Create(Gui:WaitForChild("InputBox"),
TweenInfo.new(2.0,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out
),
{
Position = UDim2.new(0.25, 0.0, -1.0, 0.0),
BackgroundTransparency = 1
}
):Play()
local IsCorrectPrompt = (Gui:WaitForChild("InputBox").Text..", is that correct?")
if Dialogue:PromptYesOrNo(IsCorrectPrompt) then
Signal:fire(Gui:WaitForChild("InputBox").Text)
Gui:WaitForChild("InputBox"):Remove()
if Finished then
Dialogue.Enabled = false
TweenBroadcastBoxOut:Play()
task.wait(1.0)
end
else
TweenService:Create(Gui:WaitForChild("InputBox"),
TweenInfo.new(2.0,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out
),
{
Position = UDim2.new(0.25, 0.0, 0.2, 0.0),
BackgroundTransparency = 0.5
}
):Play()
Gui:WaitForChild("InputBox"):CaptureFocus()
end
end
end
end
}
TweenService:Create(InputBox,
TweenInfo.new(2.0,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out
),
{
Position = UDim2.new(0.25, 0.0, 0.2, 0.0),
BackgroundTransparency = 0.5
}
):Play()
local StringInput = Signal:wait()
return StringInput
end