This one will be a bit confusing but basically I have a dialogue system, and this is the part where it displays each text string value’s value(it has code to make the typewriter effect).
The problem is, sometimes it skips some values and goes into a deeper text value.
To better explain here is a list of the text values for this NPC
Text < It reads this one
Text < It reads this one
Text < It skips this one
Text < it reads this one
Text < it skips this and the rest until
Text
Text
Text< it reads this one
Text < it reads this one
so this is confusing to me especially because I’m altering an old dialogue script I found years ago. I changed it because it used to display an “E” but now I changed it to a proximity Prompt.
I need help fixing this so it will read each text value and not skip over some.
the comments are confusing but try to understand them the best way you can.
TextBox.Parent = script.Parent
TextBox.Text = ""
TextBox.Size = UDim2.new(0.7, 0,0.35, 0)
TextBox.Position = UDim2.new(0.15, 0,0.6, 0)
TextBox.Visible = true
if TextBox.Visible == true then
print("success?")
else
print("unsuccessful")
end
for i=1,string.len(Text) do -- this is the typewritter code
TextBox.Text = string.sub(Text, 1, i)
wait(0.02)
end
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function() -- this is so you have to click the text box to continue
TextBox:Destroy()
if(TextValue:FindFirstChild("Text"))then -- varHolder is the previous text value that it was reading
VarHolder = TextValue -- text value is the child of the varholder textValue and its the current text value the code is about to read
TextValue = VarHolder.Text
Text = TextValue.Value -- text is the value of the text string value and its used to make the typewritter effect
abletochange = false
SetNewTextBox() -- this is the entire function that this code is in, the function calls itself to move on and read the next text value
wait(0.1)
else
EnableMove()
wait(1)
abletochange = true
end
end)
I’m thinking I might need a debounce but I’m not sure why I would need it.
Again this is confusing and I apologize lol.
Thanks!