Roblox Studio thought that number is a boolean

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to tell Script that its a number instead of boolean

  2. What is the issue? In the title


  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")

local player = Players.LocalPlayer

local Gui = script.Parent
local Inputer = Gui.Inputer
local Codedex = Gui.Codedex
local Indexer = Codedex.Indexer
local TopBar = Codedex.TopBar
local InfoPage = Codedex.InfoPage
local Collected = TopBar.Collected

local Remotes = ReplicatedStorage.Remotes
local SetData = Remotes.SetData

local TOModule = require(ReplicatedStorage.TOModule)

--SetData:FireServer(1, true)

local MaximumDifficultyColors = {
	[1] = Color3.fromRGB(0, 255, 0),
	[2] = Color3.fromRGB(50, 125, 0),
	[3] = Color3.fromRGB(175, 255, 0),
	[4] = Color3.fromRGB(255, 255, 0),
	[5] = Color3.fromRGB(255, 200, 0),
	[6] = Color3.fromRGB(255, 150, 0),
	[7.5] = Color3.fromRGB(255, 0, 0),
	[math.huge] = Color3.fromRGB(100, 100, 100),
}

local CodeConfig = {
	[1] = {
		["Code"] = "yourf1rstc0de",
		["CaseMatter"] = false,
		["Hint"] = "Its literally in front of you bruh.",
		["Description"] = "No Description.",
		["Difficulty"] = 0.1,
		["CustomIndexUI"] = nil,
		["CustomInfoUI"] = nil,
	},
}

for num, info in pairs(CodeConfig) do
	--pcall(function()
		print(num)
	
		local index = info.CustomIndexUI or Indexer:FindFirstChild("0")
		local iinfo = info.CustomInfoUI or InfoPage:FindFirstChild("MainInfo")
		
		if index and iinfo then
			index = index:Clone() and not info.CustomIndexUI or info.CustomIndexUI
			iinfo = iinfo:Clone() and not info.CustomInfoUI or info.CustomInfoUI
		else
			return
		end
		
		print(num)
		
		index.Name = num
		index.Text = num
		index.LayoutOrder = num
		index.Visible = true
		index.Parent = Indexer
		iinfo.Description.Text = info.Description
		iinfo.Hint.Text = "Hint : " .. info.Hint
		iinfo.num.Text = num
		iinfo.Difficulty.Text = info.Difficulty
		
		print(index, iinfo)
		
		task.spawn(function()
			for max, color in pairs(MaximumDifficultyColors) do
				if max >= info.Difficulty then
					iinfo.Difficulty.TextColor3, index.TextColor3 = color, color
					break
				end
			end
		end)
		
		index.MouseButton1Click:Connect(function()
			Indexer.Visible = false
			iinfo.Visible = true
			
			iinfo.num.MouseButton1Click:Wait()
			
			iinfo.Visible = false
			Indexer.Visible = true
		end)
	--end)
end

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Return then
		for num, info in pairs(CodeConfig) do
			if info.Code == Inputer.Text or (info.Code:lower() == Inputer.Text:lower() and not info.CaseMatter) then
				task.spawn(function()
					Inputer.TextEditable = false
					Inputer.Text = "Code Correct!"
					Inputer.TextColor3 = Color3.fromRGB(0, 255, 0)

					task.wait(3)

					Inputer.TextColor3 = Color3.fromRGB(0, 0, 0)
					Inputer.Text = ""
					Inputer.TextEditable = true
				end)
			elseif Inputer.TextEditable then
				Inputer.TextEditable = false
				Inputer.Text = "Code Invaild!"
				Inputer.TextColor3 = Color3.fromRGB(255, 0, 0)

				task.wait(3)

				Inputer.TextColor3 = Color3.fromRGB(0, 0, 0)
				Inputer.Text = ""
				Inputer.TextEditable = true
			end
		end
	end
end)

--[[for _, code in pairs(Indexer:GetChildren()) do
	if code:IsA("TextButton") then
		code.MouseButton1Click:Connect(function()
			local IndexInfo = InfomationPage:FindFirstChild(code.Name)
			
			assert(IndexInfo, "Index's Info not found or Developer forgot to add.")
			
			local InfoPage = IndexInfo.Info
			local BackButton = IndexInfo.Back
			
			IndexInfo.Visible = true
			
			task.spawn(function()
				print("e")
				
				for dif, color in pairs(MaximumDifficultyColors) do
					print(dif)
					
					if dif >= tonumber(InfoPage.Difficulty.Text) then
						print(color, color.R, MaximumDifficultyColors)
						InfoPage.Difficulty.TextColor3 = color
						break
					end
				end
			end)
			
			BackButton.Text = InfoPage.num.Text 
			
			BackButton.MouseButton1Click:Wait()
			
			IndexInfo.Visible = false
		end)
	end
end

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Return then
		local Code = Inputer.Text
		local Index = Indexer:FindFirstChild(Code)
		local IndexInfo = InfomationPage:FindFirstChild(Code)
		
		if Index and IndexInfo then
			task.spawn(function()
				Inputer.TextEditable = false
				Inputer.Text = "Code Correct!"
				Inputer.TextColor3 = Color3.fromRGB(0, 255, 0)
				
				task.wait(3)
				
				Inputer.TextColor3 = Color3.fromRGB(0, 0, 0)
				Inputer.Text = ""
				Inputer.TextEditable = true
			end)
		elseif Inputer.TextEditable then
			Inputer.TextEditable = false
			Inputer.Text = "Code Invaild!"
			Inputer.TextColor3 = Color3.fromRGB(255, 0, 0)

			task.wait(3)

			Inputer.TextColor3 = Color3.fromRGB(0, 0, 0)
			Inputer.Text = ""
			Inputer.TextEditable = true
		end
	end
end)]]

Also the issue of the code (Not include entire)

print(num) --Line 48
	
		local index = info.CustomIndexUI or Indexer:FindFirstChild("0")
		local iinfo = info.CustomInfoUI or InfoPage:FindFirstChild("MainInfo")
		
		if index and iinfo then
			index = index:Clone() and not info.CustomIndexUI or info.CustomIndexUI
			iinfo = iinfo:Clone() and not info.CustomInfoUI or info.CustomInfoUI
		else
			return
		end
		
		print(num) --Line 60
		
		index.Name = num
		index.Text = num
		index.LayoutOrder = num
		index.Visible = true
		index.Parent = Indexer
		iinfo.Description.Text = info.Description
		iinfo.Hint.Text = "Hint : " .. info.Hint
		iinfo.num.Text = num
		iinfo.Difficulty.Text = info.Difficulty

Also it happens with index.Text too

Index is a TextButton btw

Thanks for reading :smiley:

Replace “pairs” with “ipairs”.

It didnt work, I tried it (Not before)

I feel like the issue is in the “index” instance. Because the .Name property gets applied without any error. And it errors at .Text which could be an issue with the index instance maybe?

Oh, Its a textbutton, Srry for late reply tho

Are you sure…? It doesn’t seem like it. I would say it SHOULD error at “.Name” as well. Try adding a “tostring()” around the “num” while you set the “.Text” property.

If you check the error, it says “attempt to index boolean with Text” so basically it’s the element which you tried to access the Text member of.
That’s not num, that’s index.

This will result in a boolean. Try this:

index = if info.CustomIndexUI then info.CustomIndexUI else index:Clone()

or this:

index = info.CustomIndexUI or index:Clone()

OH, Im so stupid, Boolean with Name is not num is a boolean, It is index is a boolean, Tysm for helping me :smiley:

1 Like

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