Error with my code?

I’m getting this error:

  01:00:51.774  Players.matt1020304050.PlayerGui.ScreenGui.TextLabel.LocalScript:11: attempt to call a nil value  -  Client - LocalScript:11
  01:00:51.774  Stack Begin  -  Studio
  01:00:51.774  Script 'Players.matt1020304050.PlayerGui.ScreenGui.TextLabel.LocalScript', Line 11 - function matrixText  -  Studio - LocalScript:11
  01:00:51.774  Script 'Players.matt1020304050.PlayerGui.ScreenGui.TextLabel.LocalScript', Line 25  -  Studio - LocalScript:25
  01:00:51.774  Stack End  -  Studio
local function matrixText(text)
	-- Initialize variables
	local matrixText = ""
	local charList = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "[", "]", "{", "}", "\\", "|", ";", ":", "'", ",", ".", "/", "?", " "}
	math.randomseed(tick())

	-- Iterate through each character in the text string
	for i = 1, #text do
		wait(0.1)
		local char = text:sub(i, i)
		if table.indexOf(charList, char) then
			matrixText = matrixText..char
		else
			matrixText = matrixText.."?"
		end
	end

	-- Return the matrix text
	return matrixText
end

local textLabel = script.Parent
print(script.Parent)
-- Call the matrixText function and assign the result to matrixStyleText
local matrixStyleText = matrixText("hello world")

-- Get the TextLabel object


-- Set the Text property of the TextLabel object to the matrix-style text
textLabel.Text = matrixStyleText

Try changing table.indexOf to table.find

1 Like

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