Attempt to index boolean with 'Value'

Hello. I was scripting when I ran into this error I can’t solve.

attempt to index Boolean with ‘Value’

Here’s the script and don’t worry I marked where the error is:

local dataStoreService = game:GetService("DataStoreService")
local wallbucksDataStore = dataStoreService:GetDataStore("wallbucksDataStore")
local pickaxesDataStore = dataStoreService:GetDataStore("pickaxesDataStore")

local events = game:GetService("ReplicatedStorage"):WaitForChild("Events")
local mineEvent = events:WaitForChild("Mine")
local purchasePickaxeEvent = events:WaitForChild("PurchasePickaxe")

local wallBucks

local function playerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = player
	leaderstats.Name = "leaderstats"
	
	wallBucks = Instance.new("IntValue")
	wallBucks.Parent = leaderstats
	wallBucks.Name = "Wallbucks"
	wallBucks.Value = 100
	
	local playerUserId = "Player_"..player.UserId
	
	local pickaxesOwned = Instance.new("Folder")
	pickaxesOwned.Parent = player
	pickaxesOwned.Name = "pickaxesOwned"
	
	local normalPickaxeBoolean = Instance.new("BoolValue")
	normalPickaxeBoolean.Parent = pickaxesOwned
	normalPickaxeBoolean.Name = "NormalPickaxe"
	normalPickaxeBoolean.Value = false
	
	local stainlessSteelPickaxeBoolean = Instance.new("BoolValue")
	stainlessSteelPickaxeBoolean.Parent = pickaxesOwned
	stainlessSteelPickaxeBoolean.Name =  "StainlessSteelPickaxe"
	stainlessSteelPickaxeBoolean.Value = false
	
	local titaniumPickaxeBoolean = Instance.new("BoolValue")
	titaniumPickaxeBoolean.Parent = pickaxesOwned
	titaniumPickaxeBoolean.Name = "TitaniumPickaxe"
	titaniumPickaxeBoolean.Value = false
	
	local heavyDutyPickaxeBoolean = Instance.new("BoolValue")
	heavyDutyPickaxeBoolean.Parent = pickaxesOwned
	heavyDutyPickaxeBoolean.Name = "HeavyDutyPickaxe"
	heavyDutyPickaxeBoolean.Value = false
	
	local photonPickaxeBoolean = Instance.new("BoolValue")
	photonPickaxeBoolean.Parent = pickaxesOwned
	photonPickaxeBoolean.Name = "PhotonPickaxe"
	photonPickaxeBoolean.Value = false
	
	local lavaPickaxeBoolean = Instance.new("BoolValue")
	lavaPickaxeBoolean.Parent = pickaxesOwned
	lavaPickaxeBoolean.Name = "LavaPickaxe"
	lavaPickaxeBoolean.Value = false
	
	local holyPickaxeBoolean = Instance.new("BoolValue")
	holyPickaxeBoolean.Parent = pickaxesOwned
	holyPickaxeBoolean.Name = "HolyPickaxe"
	holyPickaxeBoolean.Value = false
	
	local plasmaPickaxeBoolean = Instance.new("BoolValue")
	plasmaPickaxeBoolean.Parent = pickaxesOwned
	plasmaPickaxeBoolean.Name = "PlasmaPickaxe"
	plasmaPickaxeBoolean.Value = false
	
	local darkMatterPickaxeBoolean = Instance.new("BoolValue")
	darkMatterPickaxeBoolean.Parent = pickaxesOwned
	darkMatterPickaxeBoolean.Name = "DarkMatterPickaxe"
	darkMatterPickaxeBoolean.Value = false
	
	local crystalPickaxeBoolean = Instance.new("BoolValue")
	crystalPickaxeBoolean.Parent = pickaxesOwned
	crystalPickaxeBoolean.Name = "CrystalPickaxe"
	crystalPickaxeBoolean.Value = false
	
	local equippedPickaxe = Instance.new("ObjectValue")
	equippedPickaxe.Parent = player
	equippedPickaxe.Name = "EquippedPickaxe"
	
	local normalPickaxeData
	local stainlessSteelPickaxeData
	local titaniumPickaxeData
	local heavyDutyPickaxeData
	local photonPickaxeData
	local lavaPickaxeData
	local holyPickaxeData
	local plasmaPickaxeData
	local darkMatterPickaxeData
	local crystalPickaxeData
	
	local equippedPickaxeData
	
	local success,errormessage = pcall(function()
		normalPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)
	if success then
		normalPickaxeBoolean.Value = normalPickaxeData -- error is here
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		stainlessSteelPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)
	if success then
		stainlessSteelPickaxeBoolean.Value = stainlessSteelPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		titaniumPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		titaniumPickaxeBoolean.Value = titaniumPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		heavyDutyPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		heavyDutyPickaxeBoolean.Value = heavyDutyPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		photonPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		photonPickaxeBoolean.Value = photonPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		lavaPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)
	if success then
		lavaPickaxeBoolean.Value = lavaPickaxeData
	else
		warn(errormessage)
	end
	
	local success,errormessage = pcall(function()
		holyPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		holyPickaxeBoolean.Value = holyPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		plasmaPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		plasmaPickaxeBoolean.Value = plasmaPickaxeData
	else
		warn(errormessage)
	end
	local success,errormessage = pcall(function()
		darkMatterPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
	end)

	if success then
		darkMatterPickaxeBoolean.Value = darkMatterPickaxeData
	else
		warn(errormessage)
	end
	
	local wallBucksData
	
	local success,errormessage = pcall(function()
		wallBucksData = wallbucksDataStore:GetAsync(playerUserId)
	end)
	
	if success then
		wallBucks.Value = wallBucksData
	else
		warn(errormessage)
	end
	
	mineEvent.OnServerEvent:Connect(function(player,wallbucksEarned)
		print(player,wallbucksEarned)
		wallBucks.Value = wallBucks.Value + wallbucksEarned
	end)

	purchasePickaxeEvent.OnServerEvent:Connect(function(player,pickaxe,cost)
		wallBucks.Value = wallBucks.Value - cost
		if cost == 100 then
			normalPickaxeBoolean.Value = true
		end
		if cost == 250 then
			stainlessSteelPickaxeBoolean.Value = true
		end
		if cost == 1350 then
			titaniumPickaxeBoolean.Value = true
		end
		if cost == 10000 then
			heavyDutyPickaxeBoolean.Value = true
		end
		if cost == 50000 then
			photonPickaxeBoolean.Value = true
		end
		if cost == 250000 then
			lavaPickaxeBoolean.Value = true
		end
		if cost == 1000000 then
			holyPickaxeBoolean.Value = true
		end
		if cost == 50000000 then
			plasmaPickaxeBoolean.Value = true
		end
		if cost == 1000000000 then
			darkMatterPickaxeBoolean.Value = true
		end
	end)
end

local function playerRemoving(player)
	local playerUserId = "Player_"..player.UserId
	
	local normalPickaxeData = player.pickaxesOwned.NormalPickaxe.Value
	
	local success,errormessage = pcall(function()
		pickaxesDataStore:SetAsync(playerUserId,normalPickaxeData)
	end)
	
	local wallBucksData = player.leaderstats.Wallbucks.Value
	
	local success,errormessage = pcall(function()
		wallbucksDataStore:SetAsync(playerUserId,wallBucksData)
	end)
end

game:GetService("Players").PlayerAdded:Connect(playerAdded)
game:GetService("Players").PlayerRemoving:Connect(playerRemoving)

You changed the normalPickaxeValue, which means it isn’t a BoolValue anymore

local success,errormessage = pcall(function()
	normalPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
end)
if success then
	normalPickaxeBoolean.Value = normalPickaxeData -- error is here
else
	warn(errormessage)
end

Yeah think @MrFinkyDoodles should swap both of them.

Alright I will try to swap them

Sorta like this?

if success then
	normalPickaxeBoolean.Value = normalPickaxeData
else
	warn(errormessage)
end
local success,errormessage = pcall(function()
	normalPickaxeBoolean = pickaxesDataStore:GetAsync(playerUserId)
end)

I switched the name of the variable on line 2

local success,errormessage = pcall(function()
	normalPickaxeData = pickaxesDataStore:GetAsync(playerUserId)
end)

if success then
	normalPickaxeBoolean.Value = normalPickaxeData
else
	warn(errormessage)
end

Ohhhhhhhhhhh that makes so much sense

1 Like

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