Issue when creating IntValue with

I’m trying to make an Inventory system and the way I’m setting the maximum number of inventory items a player can have is through an IntValue within a folder inside the player. The issue is, when I create the IntValue, it seems to have an issue with setting its parent.

Code Snippet:

    local playerInventoryFolder = sentPlayer:FindFirstChild('Inventory') or'Folder');
	local playerInventorySettings = playerInventoryFolder:FindFirstChild('Settings') or'Folder');
	local inventorySizeSetting = playerInventorySettings:FindFirstChild('Size') or'IntValue');
	playerInventoryFolder.Name = 'Inventory';
	playerInventorySettings.Name = 'Settings';
	inventorySizeSetting.Name = 'Size';

    playerInventoryFolder.Parent = sentPlayer;
	playerInventorySettings.Parent = playerInventoryFolder;
	newInventorySize.Parent = playerInventorySettings;
	inventorySizeSetting.Value = newInventorySize;

Prematurely Posted:

Here’s the output error -

  23:55:55.911 - ReplicatedStorage.Modules.inventoryModule:20: attempt to index number with 'Parent'

The issue is that I’m not making the variable inventorySizeSetting the value of the IntValue Instance, I’m just making it the IntValue Instance, yet it seems to think I’m making it the Value of the IntValue Instance.

Any errors in output? At all? You should outline these things before posting.

is newInventorySize a numbervalue/intvalue? It seems like you are trying to set it to the instance and not the actual value.

Yes, if you read the code, since it could not find the InvtValue named "Size" within the folder, it creates an IntValue for it.

As seen by

local inventorySizeSetting = playerInventorySettings:FindFirstChild('Size') or'IntValue');

You still haven’t set newInventorySize in the visible code.

Lol, I’ve realized my mistake, nevermind.