I’m using roblox’s TypeWrite module but I want It to start typing when the text Is visible
I tried using if and propertychanged but It didn’t work, I have no Idea how to make It work
Normal script: (works)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
TypeWriter.typeWrite(script.Parent, "test")
Script that I tried to make It work: (breaks the script)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
if script.Parent.Visible == true then
TypeWriter.typeWrite(script.Parent, "test")
end
I’m pretty bad at typeWrite, any Ideas? (btw I used the devhub for this)
You mean GetPropertyChangedSignal?
Also the problem might be that the TextLabel (or whatever gui element you’re using) is becoming visible before the script runs.
Nope, and yes i meant GetPropertyChangedSignal, btw sorry for late response, I mean when the text becomes visible theres no text and It works for other ones except this one.
Here you go, the following works well. I removed translation, because it takes some time.
Unfold this to get the module without translation function (faster).
local TypeWriter = {}
local defaultConfigurations = {
delayTime = .08,
extraDelayOnSpace = false
}
function TypeWriter.configure(configurations)
for key, value in pairs(defaultConfigurations) do
local newValue = configurations[key]
if newValue ~= nil then
defaultConfigurations[key] = newValue
else
warn(key .. " is not a valid configuration for TypeWriter module")
end
end
end
function TypeWriter.typeWrite(guiObject, text)
guiObject.AutoLocalize = false
guiObject.Text = ""
local displayText = text
for first, last in utf8.graphemes(displayText) do
local grapheme = string.sub(displayText, first, last)
guiObject.Text = guiObject.Text .. grapheme
if defaultConfigurations.extraDelayOnSpace and grapheme == " " then
wait(defaultConfigurations.delayTime)
end
wait(defaultConfigurations.delayTime)
end
end
return TypeWriter
And here is a .rbxm file with the GUI. Download it and drag it with a mouse into an open workspace.
There are two scripts inside: TextWriter, which listens for property changes and later calls the function
local TypeWriter = require(game:GetService("ReplicatedStorage"):WaitForChild("TypeWriter"))
local TEXT = "This type writer is working like a charm!\n Warm regards, EssenceExplorer"
script.Parent:GetPropertyChangedSignal("Visible"):Connect(function()
if (script.Parent.Visible) then
TypeWriter.typeWrite(script.Parent, TEXT)
end
end)
and PropertyChanger, which make your GUI visible.
local player = game:GetService("Players").LocalPlayer
-- Wait for character to load.
if (not player.Character) then player.CharacterAdded:Wait() end
-- After character loads, wait aditional 3 seconds.
wait(3)
script.Parent.Visible = true