That’s because you only ever reference the 1st index in the table, that being the first part in the folder. Heres a script that does what you ask. Replace part.Touched
function with the code below and put all of the code inside of your “touched” function into the code below; right under text = v:FindFirstChildWhichIsA("StringValue").Value
for Index,Part in pairs(info) do
Part.Touched:Connect(function()
local text = Part:FindFirstChildWhichIsA("StringValue").Value
end)
end
I would also like to mention that using that repeat until
is unnecessary as you can just use a Tween; which basically does exactly what you’re trying to achieve with the repeat until
.
Heres code of the tween if you would like to do that instead. Place this at the top of the script:
local TweenService = game:GetService("TweenService")
local TweenOptions = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0) -- you can change any of these options to your liking
Replace the repeat until
with this:
local TweenTextTransparency = TweenService:Create(script.Parent,TweenOptions,{TextTransparency = 1})
TweenTextTransparency:Play()
TweenTextTransparency.Completed:Connect(function() -- detects when the tween ends
db = false
end)
Final script with the tween:
repeat task.wait(1) until game.Loaded
local typeSound = game.SoundService.letterType
local mainFolder = game.Workspace.textTouchParts
local db = false
local TweenService = game:GetService("TweenService")
local TweenOptions = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
local info = {}
for i,v in pairs(mainFolder:GetChildren()) do
table.insert(info,v)
end
for Index,Part in pairs(info) do
Part.Touched:Connect(function()
local text = Part:FindFirstChildWhichIsA("StringValue").Value
if db == false then
db = true
for i = 1, #text do
script.Parent.Text = string.sub(text,1,i)
typeSound:Play()
task.wait(0.075)
end
task.wait(2)
local TweenTextTransparency = TweenService:Create(script.Parent,TweenOptions,{TextTransparency = 1})
TweenTextTransparency:Play()
TweenTextTransparency.Completed:Connect(function()
db = false
end)
end
table.remove(info,Index)
Part:Destroy()
end)
end