"attempt to get length of a nil value?"

You can write your topic however you want, but you need to answer these questions:
I want to make a typewriter effect and this is the script:

local function TypewriterEffect(object, text)
	for i = 1, #text, 1 do -- Error Here
		object.Text = string.sub(text, 1, i)
		task.wait(.05)
	end
end

The issue is that it gives an error that says “attempt to get length of a nil value.”

I don’t know how to fix this, and for extra information, this is on a server script.

The whole script:

-- Variables
local Player = game:GetService("Players").PlayerAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local PlayerGui = Player.PlayerGui
local AllGUIs = PlayerGui:WaitForChild("AllGUIs")
local SecretTrue = ServerStorage.BindableEvents.SecretTrue
local InfoLabel = AllGUIs.UIElements.InfoLabel
local button = AllGUIs.UIElements.ChangeColor
local debounce = false
-----------------------------------------------------------------------------------------------------------------------------------

-- TypewriterEffect Function
local function TypewriterEffect(object, text)
	for i = 1, #text, 1 do -- Error Here
		object.Text = string.sub(text, 1, i)
		task.wait(.05)
	end
end
-----------------------------------------------------------------------------------------------------------------------------------

-- Secret

SecretTrue.Event:Connect(function(Player)
	AllGUIs.LocalScripts.RGB_RNG.Enabled = false
	AllGUIs.LocalScripts.TextLabelEditor.Enabled = false

	InfoLabel.BackgroundColor3 = Color3.new(1, 1, 1)


	TypewriterEffect("-- Secret")


	InfoLabel:TweenSize(
		UDim2.new(0, 475, 0, 70),
		Enum.EasingDirection.In,
		Enum.EasingStyle.Sine,
		.7,
		true
)

	task.wait(1.5)

	TypewriterEffect("-- Secret")

	button.MouseButton1Click:Once(function()
		if not debounce then
			debounce = true

			TypewriterEffect("-- Secret")

			task.wait(1.5)

			TypewriterEffect("-- Secret")

			task.wait(1.5)

			TypewriterEffect("-- Secret")

			task.wait(1.5)

			TypewriterEffect("-- Secret")

			task.wait(1.5)
				
			Player:Kick("-- Secret")

			debounce = false
		end
	end)
end)
-----------------------------------------------------------------------------------------------------------------------------------

the function has 2 arguments while you pass only 1

try this:

TypewriterEffect(InfoLabel, "-- Secret")
1 Like

I forgot to remove the object one lol… kinda embarrasing. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.