So I have a script and the first few lines im declaring variables and Ive checked where it goes wrong and it’s when I require the typewrite module, I dont know why it doesnt work, it doesnt print after I require it but if i put the print before it, it works prints
local PASSWORD = "fudge"
local USERNAME = "fudge"
local plr = game.Players.LocalPlayer
local char = plr.Character
local ScreenGUI = plr.PlayerGui:WaitForChild("ScreenUI")
local Screen = ScreenGUI.Screen
local UNIX = ScreenGUI.Screen.Version
local loggin = ScreenGUI.Screen.loggin
--// Modules
local Methods = require(game.ReplicatedStorage.Functions)
local TypeWrite = require(game.ReplicatedStorage.Type)
print("testing")
Yes I made sure to return the module, Im not sure what it’s not working
Heres the module
local SOURCE_LOCALE = "en"
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local translator = nil
pcall(function()
translator = LocalizationService:GetTranslatorForPlayerAsync(player)
end)
if not translator then
pcall(function()
translator = LocalizationService:GetTranslatorForLocaleAsync(SOURCE_LOCALE)
end)
end
local TypeWriter = {}
local defaultConfigurations = {
delayTime = 0.2,
extraDelayOnSpace = true
}
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
if translator then
displayText = translator:Translate(guiObject, text)
end
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
Then it’ll error because ‘fudge’ would be nil unless defined.
@PlayingRobIoxStudio what type of script is this and where is it located?
If you need to index Ui components then just put it at the lowest level at its hierarchy under the Gui, to avoid using WaitForChild where possible.
With your current implementation, there’s the chance PlayerGui won’t exist because you didn’t yield to guarantee its existence, and the Character doesn’t exist immediately too by the way.
local char = plr.Character or plr.CharacterAdded:Wait()
I see it’s a bit impossible to communicate to you through direct messages, so I’ll just do it here.
How can you be so sure? Surely you’d like to use better practices where possible?
When the character exists and you do player.Character it obviously won’t error, but the former (i.e in my post) allows it to yield until the character exists for preventing errors in cases where the character isn’t parented to workspace yet.
Edit:
I don’t think you understand that I meant for you to use that practice generally whenever you’re accessing the character, there could be a thousand different ways you’re naively doing it- but as I said, that won’t always work and it really isn’t as simple as that.