Attempt to index boolean with 'Value' and Weird scrolling frame bug

Hello, and I have 2 problems with my inventory system.
The first one is shown here:

I have bool value called Selected located in template for each item.

image

When I try to do something with Selected value it gives an error:

image

Script (not full)

local function addToFrame(pet)

	local newTemplate = template:Clone()
	newTemplate.Name = pet.Name
	newTemplate.PetName.Text = pet.Name
	newTemplate.Parent = scrollingFrame
	newTemplate.RealName.Value = pet.Name
	
	if pet:FindFirstChild("Legendary") then
		newTemplate.PetName.TextColor3 = leg
	end 
	
	if pet:FindFirstChild("Epic") then
		newTemplate.PetName.TextColor3 = epic
	end 
	
	if pet:FindFirstChild("Rare") then
		newTemplate.PetName.TextColor3 = rare
	end 
	
	if pet:FindFirstChild("Common") then
		newTemplate.PetName.TextColor3 = comm
	end 
	
	newTemplate.TextButton.MouseButton1Click:Connect(function()
		newTemplate.WarningFrame.Visible = true
	end)
	
	newTemplate.WarningFrame.Yes.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.DeletePet:FireServer(pet.Name)
		newTemplate:Destroy()
	end)
	
	newTemplate.WarningFrame.No.MouseButton1Click:Connect(function()
		newTemplate.WarningFrame.Visible = false
	end)
	
	local newPet = pet:Clone()
	newPet.Parent = newTemplate.ViewportFrame

	local camera = Instance.new("Camera")
	camera.CFrame = CFrame.new(newPet.Handle.Position + (newPet.Handle.CFrame.lookVector * 3),newPet.Handle.Position)
	camera.Parent = newTemplate.ViewportFrame

	newTemplate.ViewportFrame.CurrentCamera = camera

	buttonConnections[#buttonConnections+1] = newTemplate.MouseButton1Click:Connect(function()
		if script.MultiDelete.Value == true then
			--if newTemplate.Selected.Value == false then
			--newTemplate.Selected.Value = true
			print("select: "..newTemplate.Selected.Value)
				newTemplate.BackgroundColor3 = Color3.fromRGB(255, 139, 139)
				local newValue = Instance.new("StringValue")
				newValue.Name = newTemplate.RealName.Value
				newValue.Parent = script.MultiDelete
			--end
		--elseif script.MultiDelete.Value == true then
			--if newTemplate.Selected.Value == true then
				--newTemplate.Selected.Value = false
				--newTemplate.BackgroundColor3 = Color3.fromRGB(43, 43, 43)
				--script.MultiDelete:FindFirstChild(newTemplate.RealName.Value):Destroy()
			--end
		end	
		if newTemplate.Equipped.Text == "EQUIPPED" and script.MultiDelete.Value == false then	
			game.ReplicatedStorage.UnequipPet:FireServer(pet)	
			newTemplate.Name = "UnequippedItem"
			newTemplate.Equipped.Text = "UNEQUIPPED"
			newTemplate.BackgroundColor3 = Color3.fromRGB(43, 43, 43)
			newTemplate.Equipped.TextColor3 = Color3.fromRGB(255, 255, 255)
		else
			if plr.EquippedPet.Value == "" and script.MultiDelete.Value == false then
				game.ReplicatedStorage.EquipPet:FireServer(pet.Name, "EquippedPet")
				setTemplateEquipped(newTemplate, 1, pet.Name)
			end
			if plr.EquippedPet_2.Value == "" and plr.EquippedPet.Value ~= "" and script.MultiDelete.Value == false then
				game.ReplicatedStorage.EquipPet:FireServer(pet.Name, "EquippedPet_2")
				setTemplateEquipped(newTemplate, 2, pet.Name)
			end
			if plr.EquippedPet_3.Value == "" and plr.EquippedPet_2.Value ~= "" and plr.EquippedPet.Value ~= "" and script.MultiDelete.Value == false then
				game.ReplicatedStorage.EquipPet:FireServer(pet.Name, "EquippedPet_3")
				setTemplateEquipped(newTemplate, 3, pet.Name)
			end
		end
	end)	
end

The error is at this line:

print("select: "..newTemplate.Selected.Value)

The second bug is shown here:

When I change cell padding of scrolling frame it’s just looks soo weird, the cell padding I use:

gridLayout.CellSize = UDim2.new(0.2, 0, 0.37, 0)

it fixes only when I change it to offset.

There’s the explorer:

image

UIGridLayout’s Properties:

How it should look like:

image

Thanks for the help :slight_smile:

sorry, my bad, the template has property called Selected and the script thought I was calling that property, but I still have problems with second bug

You could try to use the absolute size of the scrolling frame (or the main frame) to get the offset

ok, I can try, also theres the multi delete :slight_smile:

Edit:
I used absolute size x and y for grid layout offset cell size x and y, but the result is this:

I will try to make it smaller with x / 20 or idk and with y same

  • does multi delete have any bugs? because I can’t figure out if there are any bugs from the video

  • Do you tried to do something like:

local size = scrollingFrame.AbsoluteSize.X / xCells -- im not sure about this btw

gridLayout.CellSize = UDim2.new(0, size, 0, size)

no it doesn’t seem to show any bugs, it saves and deletes even equipped items.

I have this function:

local function updateCellSize(scrollingFrame)
	local gridLayout = scrollingFrame.UIGridLayout
	local size = scrollingFrame.AbsoluteSize.X / gridLayout.CellSize.X.Offset
	gridLayout.CellSize = UDim2.fromOffset(size, size)
end

but what if I have my cell size set to Udim2.new(0,0,0,0)? Cause I set it with script

local size = scrollingFrame.AbsoluteSize.X / gridLayout.CellSize.X.Offset

Try to replace the gridLayout.CellSize.X.Offset with the number of cells you want in a line

1 Like

so it would look like this

local function updateCellSize(scrollingFrame)
	local gridLayout = scrollingFrame.UIGridLayout
	local size = scrollingFrame.AbsoluteSize.X / 5
	print(scrollingFrame.AbsoluteSize.X / 5)
	gridLayout.CellSize = UDim2.fromOffset(size, size)
end

and in output

image

and inventory

thanks for the help :> I will also make it update when absolute size changed

1 Like