✓ Accepted answer
This isn't really a site to ask for code but rather a site to ask help with any issues in your code, but nonetheless I will help you.
You can keep a nice local script in startergui in order to handle this code.
also a folder in replicatedstorage with a booleanvalue set to false that's how I like to do these sort of things but you can use your own detection method
It's actually a lot more simple than it seems.
local textGui = script.Parent:FindFirstChild("ScreenGui"):FindFirstChild("Frame").TextLabel
local bool = game:GetService("ReplicatedStorage"):WaitForChild("bools"):FindFirstChild("touchBool")
local function typewrite(object,text,speed)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
wait(speed)
end
end
bool.Changed:Connect(function()
typewrite(textGui,"hello world",0.035)
wait(2.5)
textGui.Text = " "
end)
in order to get the boolean value to change we will need to detect if a player touches a part. we use a server script for that in serverscriptservice
local part = game.Workspace.touchTrigger
part.Touched:Connect(function(touchPart)
local humanoid = touchPart.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
game:GetService("ReplicatedStorage"):WaitForChild("bools"):FindFirstChild("touchBool").Value = true
end
end)
Sorry if this doesn't explain much I had to rush this.
If you have any more questions you can look through the dev wiki to learn how lua works and how it works with roblox and such
https://developer.roblox.com/en-us/