function UpgradeManager.AddUpgrade(u,l)local k=l:WaitForChild("\115\116\097\116\115")local T=k:WaitForChild(GameSettings.pointsName)local N=k:WaitForChild(GameSettings.upgradeName)N.Value=N.Value+1 u:SetWalkspeedToCurrentUpgrade(l)ParticleController:CreateUpgradeParticle(l)DataStore:SetPoints(l,T.Value)DataStore:SetUpgrades(l,N.Value)end function UpgradeManager.BuyUpgrade(u,l)local k=l:WaitForChild("\115\116\097\116\115")local T=k:WaitForChild(GameSettings.pointsName)local N=k:WaitForChild(GameSettings.upgradeName)local q=GameSettings.upgradeCost(N.Value)if T.Value>=q then T.Value=T.Value-q N.Value=N.Value+1 u:SetWalkspeedToCurrentUpgrade(l)DataStore:SetPoints(l,T.Value)DataStore:SetUpgrades(l,N.Value)ParticleController:CreateUpgradeParticle(l)else end end return UpgradeManager

function UpgradeManager:AddUpgrade(player)
	local stats = player:WaitForChild("stats")
	local points = stats:WaitForChild(GameSettings.pointsName)
	local upgrades = stats:WaitForChild(GameSettings.upgradeName)
	upgrades.Value = upgrades.Value + 1
	self:SetWalkspeedToCurrentUpgrade(player)
	ParticleController:CreateUpgradeParticle(player)
	
	DataStore:SetPoints(player, points.Value)
	DataStore:SetUpgrades(player, upgrades.Value)
end

function UpgradeManager:BuyUpgrade(player)
	local stats = player:WaitForChild("stats")
	local points = stats:WaitForChild(GameSettings.pointsName)
	local upgrades = stats:WaitForChild(GameSettings.upgradeName)
	
	local cost = GameSettings.upgradeCost(upgrades.Value)
	
	-- Check if the player can make the purchase and if so, allow them
	if points.Value >= cost then
		points.Value = points.Value - cost
		upgrades.Value = upgrades.Value + 1
		self:SetWalkspeedToCurrentUpgrade(player)
		
		DataStore:SetPoints(player, points.Value)
		DataStore:SetUpgrades(player, upgrades.Value)
		ParticleController:CreateUpgradeParticle(player)
	else
		-- Not enough points
	end
end

return UpgradeManager
