How to make animated text in surface gui when a player uses proximity prompt

I am new to this text style. I want to know how to make this script work

local monitor = script.Parent.Parent.Parent.Parent.Monitor
local screenText = monitor.SurfaceGui.Frame.Display
local text = screenText.Text
script.Parent.Parent.Parent.Parent.Dropper1.Clicker.ClickerPrompt.Triggered:Connect()
print("connected")
	for i = 0,#text,1 do
		screenText.Text = string.sub(text,1,i)
		wait(0.025)
	end

What exactly are you trying to do?

When a player triggers proximity prompt an animated text should start typing (1-2 words per click) if he presses 1 time a few words should be written in surface gui

You mean like a typewriter effect?

yes, I think that is what I meant

I dont really use proximity prompts, so I dont know if this will work.

local prompt = script.Parent
local text = "text here"
local gmatch = string.gmatch(text,".")
local textongui = directory.here

local function triggered(promptObject, player)
   local rand = math.random(1,2)
   repeat
   local txt = textongui.Text
   textongui.Text = txt..""..gmatch
   rand -= 1
   until rand == 0
end


ProximityPromptService.PromptTriggered:Connect(proxPromptTriggered)

Then I suggest using this property to show more or less characters in the TextLabel’s Text property.

Could you please help me? I tried searching for this but I couldn’t find anything.