Help with DataStore2

I am trying to switch over to DataStore2 so I can safely save data but Already I have encountered issues, everywhere there is a DataStore2(“String”,plr) DataStore2 is underlined in Red

local ServerScriptService = game:GetService("ServerScriptService")
local DataStore2 = require(ServerScriptService.DataStore2)
local ItemMod = require(game.ReplicatedStorage.Items)
local WhiteList = require(game.ReplicatedStorage.WhiteList)
local suffixes = {'K','M','B','T','qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'}
local function GenInt(Name,Parent,Value)
	local Int = Instance.new("IntValue")
	if Parent ~= "NoParent" then
		Int.Parent = Parent
	end
	Int.Name = Name
	Int.Value = Value
	return Int
end
local function GenNum(Name,Parent,Value)
	local Num = Instance.new("NumberValue")
	if Parent ~= "NoParent" then
		Num.Parent = Parent
	end
	Num.Name = Name
	Num.Value = Value
	return Num
end
local function GenFolder(Name,Parent)
	local Folder = Instance.new("Folder",Parent)
	Folder.Name = Name
	return Folder
end
local function GenBool(Name,Parent,Value)
	local Bool = Instance.new("BoolValue",Parent)
	Bool.Name = Name
	Bool.Value = Value
	return Bool
end
local function GenString(Name,Parent,Value)
	local String = Instance.new("StringValue",Parent)
	String.Name = Name
	String.Value = Value
end
DataStore2.Combine("MasterData","Stats","Upgrades","Items","Pets","Settings","Boosts","Equips")
game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = GenFolder("leaderstats",plr)
	local Boosts = GenFolder("Boosts",plr)
	local EventCurrencys = GenFolder("EventCurrencys",plr)
	local Chests = GenFolder("Chests",plr)
	local Settings = GenFolder("Settings",plr)
	local Pets = GenFolder("Pets",plr)
	local PetsA = GenFolder("PetsA",plr)
	local EquippedPets = GenFolder("EquippedPets",plr)
	local Upgrades = GenFolder("Upgrades",plr)
	local Clouds = GenFolder("Clouds",plr)
	local Batterys = GenFolder("Batterys",plr)
	local Backpacks = GenFolder("Backpacks",plr)
	local LagReduce = GenFolder("Pets"..plr.Name,game.ReplicatedStorage.ReduceLagPets)
	local StatsS = DataStore2("Stats",plr)
	local UpgradesS = DataStore2("Upgrades",plr)
	local ItemsS = DataStore2("Items",plr)
	local PetsS = DataStore2("Pets",plr)
	local SettingsS = DataStore2("Settings",plr)
	local BoostsS = DataStore2("Boosts",plr)
	local EquipsS = DataStore2("Equips",plr)
	
	local function SaveStats()
		local StatTable = {plr.leaderstats.Rebirths.Value,plr.leaderstats.Crystals.Value,plr.leaderstats.CloudCoins.Value,plr.leaderstats["Total Clouds"].Value,plr.leaderstats.EggsOpened.Value}
		StatsS:Set(StatTable)
	end
	local function SaveUpgrades()
		local UpgradeTable = {plr.Upgrades.Speed.Value,plr.Upgrades.MaxClouds.Value,plr.Upgrades.BonusPets.Value,plr.Upgrades.RebirthButtons.Value,plr.Upgrades.Clouds.Value,plr.Upgrades.PetNumber.Value,plr.Upgrades.XPGain.Value,plr.Upgrades.CrystalUp.Value}
		UpgradesS:Set(UpgradeTable)
	end
	local Rebirths = GenNum("Rebirths",leaderstats,0)
	local Crystals = GenNum("Crystals",leaderstats,0)
	local Coins = GenNum("CloudCoins",leaderstats,0)
	local CloudsT = GenNum("Total Clouds",leaderstats,0)
	local EggsOpened = GenNum("EggsOpened",leaderstats,0)
	local LeaderVals = StatsS:Get({0,0,0,0,0})
	Rebirths.Value = LeaderVals[1]  or 0
	Crystals.Value = LeaderVals[2] or 0
	Coins.Value = LeaderVals[3] or 0
	CloudsT.Value = LeaderVals[4] or 0
	EggsOpened.Value = LeaderVals[5] or 0
	local RebirthButtons = GenInt("RebirthButtons",Upgrades,5)
	local MaxClouds = GenInt("MaxClouds",Upgrades,1)
	local CloudsB = GenNum("Clouds",Upgrades,0)
	local Speed = GenInt("Speed",Upgrades,1)
	local BounusPets = GenInt("BonusPets",Upgrades,0)
	local FloatBoost = GenInt("FloatBoost",Upgrades,0)
	local CoinBoost = GenInt("CoinBoost",Upgrades,0)
	local PetStorage = GenInt("PetNumber",Upgrades,40)
	local Stopped = GenBool("Stopped",Upgrades,false)
	local XPGain = GenInt("XPGain",Upgrades,1)
	local Trading = GenBool("Trading",plr,false)
	local AcceptTrade = GenBool("AcceptTrade",plr,true)
	local Rank = GenString("Rank",plr,"Rookie")
	local CrystalUp = GenInt("CrystalUp",Upgrades,0)
	local PlrSpeed = GenInt("PlrSpeed",Upgrades,0)
	local World = GenString("InWorld",plr,"Spawn")
	local UpgradeVals = UpgradesS:Get({1,1,0,5,0,0,1,0})
	Speed.Value = UpgradeVals[1]
	MaxClouds.Value = UpgradeVals[2]
	BounusPets.Value = UpgradeVals[3]
	RebirthButtons.Value = UpgradeVals[4]
	CloudsB.Value = UpgradeVals[5]
	PetStorage.Value = UpgradeVals[6]+40
	XPGain.Value = UpgradeVals[7]
	CrystalUp.Value = UpgradeVals[8]
	local function SaveSettings()
		local SettingTable = {plr.Settings.ShowNoti.Value,plr.Settings.ShowPets.Value,plr.Settings.ToolEnabled.Value}
		SettingsS:Set(SettingTable)
	end
	local ShowNoti = GenBool("ShowNoti",Settings,true)
	local ToolEnabled = GenBool("ToolEnabled",Settings,true)
	local ShowPets = GenBool("ShowPets",Settings,true)
	local SettingVals = SettingsS:Get({true,true,true})
	ShowNoti.Value = SettingVals[1] or true
	ShowPets.Value = SettingVals[2] or true
	ToolEnabled.Value = SettingVals[3] or true
	local PetData = PetsS:Get({})
	if PetData ~= {} and type(PetData) == "table" then
		for _, petInfo in pairs(PetData) do
			if game.ReplicatedStorage:WaitForChild("Pets"):FindFirstChild(petInfo[1]) then
				if PetsA:FindFirstChild(petInfo[1].." Amount") then
					PetsA:FindFirstChild(petInfo[1].." Amount").Value = PetsA:FindFirstChild(petInfo[1].." Amount").Value + 1
				else
					local Amount = GenInt(petInfo[1].." Amount",PetsA,1)
				end
				local PetValue = game:GetService("ServerStorage"):WaitForChild("Pet"):Clone()
				PetValue.Name = petInfo[1]
				PetValue.Number.Value = plr.PetsA:WaitForChild(petInfo[1].." Amount").Value
				PetValue.Value = true
				PetValue.Level.Value = petInfo[2] or 1
				PetValue.XP.Value = petInfo[3] or 0
				PetValue.NickName.Value = petInfo[4] or ""
				PetValue.Locked.Value = petInfo[5] or false
				PetValue.Parent = Pets
			end
		end
	end
	local function SavePets()
		local petTable = {}
		for _, pet in pairs(plr.Pets:GetChildren()) do
			if game.ReplicatedStorage.Pets:FindFirstChild(pet.Name) then
				local petInfo = {pet.Name,pet.Number.Value,pet.XP.Value,pet.NickName.Value,pet.Locked.Value}
				table.insert(petTable, petInfo)
				wait(0.1)
				petInfo = {}
			end
		end
		PetsS:Set(petTable)
	end
	local EquippedCloud = GenString("EquippedCloud",plr,"Basic")
	local EquippedBattery = GenString("EquippedBattery",plr,"Basic")
	local EquippedBackpack = GenString("EquippedBackpack",plr,"Basic")
	local ItemData = ItemsS:Get({})
	local function ItemSift(Type,DataT)
		if DataT ~= nil and DataT ~= {} and type(DataT) == "table" then
			for i, Value in pairs(DataT) do
				for i, Item in pairs(ItemMod[Type]) do
					if Item[1] == Value and Item[2] ~= "Gamepass" and Item[2] ~= "Developer" then
						local Val = GenBool(Value,plr[Type],false)
						local Gain = GenInt(Item[8],Val,Item[6])
						local World = GenString("World",Val,Item[2])
					end
				end
			end
		end
	end
	if ItemData ~= {} and type(ItemData) == "table" then
		local CloudData = ItemData[1]
		ItemSift("Clouds",CloudData)
		local PackData = ItemData[2]
		ItemSift("Backpacks",CloudData)
		local BatteryData = ItemData[3]
		ItemSift("Batterys",CloudData)
	end
	if not Clouds:FindFirstChild("Basic") then
		local Basic = GenBool("Basic",Clouds,false)
		local FG = GenInt("FG",Basic,1)
		local World = GenString("World",Basic,"Spawn")
	end
	if not Batterys:FindFirstChild("Basic") then
		local Basic = GenBool("Basic",Batterys,false)
		local Energy = GenInt("Energy",Basic,10)
		local World = GenString("World",Basic,"Spawn")
	end
	if not Backpacks:FindFirstChild("Basic") then
		local Basic = GenBool("Basic",Backpacks,false)
		local Space = GenInt("Space",Basic,15)
		local World = GenString("World",Basic,"Spawn")
	end
	local function SaveItems()
		local Items = {}
		local Clouds = {}
		local Packs = {}
		local Batterys = {}
		for i, Type in pairs(require(game.ReplicatedStorage.Items)) do
			for i, Value in pairs(plr[Type[1]]:GetChildren()) do
				for i, Item in pairs(Type) do
					if Value.Name == Item[1] then
						if Type == "Clouds" then
							table.insert(Clouds,Value.Name)
						elseif Type == "Batterys" then
							table.insert(Batterys,Value.Name)
						elseif Type == "Backpacks" then
							table.insert(Packs,Value.Name)
						end
					end
				end
			end
		end
		table.insert(Items,Clouds)
		table.insert(Items,Packs)
		table.insert(Items,Batterys)
		ItemsS:Set(Items)
	end
	local EquipData = EquipsS:Get({"Basic","Basic","Basic","Rookie"})
	if Backpacks:FindFirstChild(EquipData[1]) then plr.EquippedBackpack.Value = EquipData[1] or plr.EquippedBackpack.Value end
	if Clouds:FindFirstChild(EquipData[2]) then plr.EquippedCloud.Value = EquipData[2] or plr.EquippedCloud.Value end
	if Backpacks:FindFirstChild(EquipData[3]) then plr.EquippedBattery.Value = EquipData[3] or plr.EquippedBattery.Value end
	plr.Rank.Value = EquipData[4] or plr.Rank.Value
	local function SaveEquips()
		local Equips = {plr.EquippedBackpack.Value,plr.EquippedCloud.Value,plr.EquippedBattery.Value,plr.Rank.Value}
		EquipsS:Set(Equips)
	end
	wait(2)
	local Val = Instance.new("BoolValue",plr)
	Val.Name = "Loaded"
	local Val2 = Val:Clone()
	Val2.Parent = plr.Character
	Rebirths.Changed:Connect(SaveStats)
	Crystals.Changed:Connect(SaveStats)
	Coins.Changed:Connect(SaveStats)
	CloudsT.Changed:Connect(SaveStats)
	EggsOpened.Changed:Connect(SaveStats)
	RebirthButtons.Changed:Connect(SaveUpgrades)
	MaxClouds.Changed:Connect(SaveUpgrades)
	CloudsB.Changed:Connect(SaveUpgrades)
	Speed.Changed:Connect(SaveUpgrades)
	BounusPets.Changed:Connect(SaveUpgrades)
	PetStorage.Changed:Connect(SaveUpgrades)
	XPGain.Changed:Connect(SaveUpgrades)
	CrystalUp.Changed:Connect(SaveUpgrades)
	ShowNoti.Changed:Connect(SaveSettings)
	ToolEnabled.Changed:Connect(SaveSettings)
	ShowPets.Changed:Connect(SaveSettings)
	Pets.ChildAdded:Connect(function()
		wait(0.5)
		SavePets()
	end)
	Pets.ChildRemoved:Connect(function()
		wait(0.5)
		SavePets()
	end)
	Clouds.ChildAdded:Connect(SaveItems)
	Backpacks.ChildAdded:Connect(SaveItems)
	Batterys.ChildAdded:Connect(SaveItems)
	plr.Rank.Changed:Connect(SaveEquips)
	plr.EquippedBackpack.Changed:Connect(SaveEquips)
	plr.EquippedCloud.Changed:Connect(SaveEquips)
	plr.EquippedBattery.Changed:Connect(SaveEquips)
end)

saying: Cannot Call non Function. I have already used require() to get the DataStore2. But even though that happens when the game runs it works Perfectly fine, I don’t know if this is a roblox bug/issue or what.

– You have to define a module before being able to use its functions.
require(script.Parent.MainModule)

I did, I was just showing the line of code and telling the error.

Can you show us all the scripts?

Sure! I Will edit the Post to show my entire script!

Since the original post I had worked on multiple variations of the script the one above is a finished version but still has the same problem. The only difference is now I know its a bug because nothing breaks/doesn’t work when I load the game.