CubicV2 is not EasingStyle?

In my game I use very interestin Animation system, but now I saw, that script stop working

local TweenService = game:GetService("TweenService")

local round = math.round
local getValue = TweenService.GetValue
local easingDirections = Enum.EasingDirection:GetEnumItems()

local easingFuncs = {}

for _, poseEasingStyle in Enum.PoseEasingStyle:GetEnumItems() do
	if poseEasingStyle == Enum.PoseEasingStyle.Constant then
		continue
	end
	local directions = {}
	local easingStyle = Enum.EasingStyle[poseEasingStyle.Name]
	for _, direction in easingDirections do

		directions[direction.Value] = function(a)
			return getValue(TweenService, a, easingStyle, direction)
		end
	end
	easingFuncs[poseEasingStyle.Value] = directions
end

easingFuncs[Enum.PoseEasingStyle.Constant.Value] = {
	[0] = round,
	[1] = round,
	[2] = round,
}

local function getLerpAlpha(a, poseEasingStyleValue, poseEasingDirectionValue)
	return easingFuncs[poseEasingStyleValue][poseEasingDirectionValue](a)
end

return getLerpAlpha

He give me error - CubicV2 is not a valid member of “Enum.EasingStyle”

  • [I tried to put checks like, if ?.Name == “CubicV2” then print(“ldalsdalds”) but it doesn’t work. Help!

The problem is that the system relies on all PoseEasingStyles being identical to all EasingStyles, but recently Roblox added CubicV2 to PoseEasingStyles and not to EasingStyles. They may add it to EasingStyles in the future. But for now, to solve this I think updating the getLerpAlpha function to this new adjusted one I wrote should identify whether the EasingStyle exists. If not, the we just fall back on Cubic

local function getLerpAlpha(a, poseEasingStyleValue, poseEasingDirectionValue)
	if easingFuncs[poseEasingStyleValue] then
		return easingFuncs[poseEasingStyleValue][poseEasingDirectionValue](a)
	else
		return easingFuncs[Enum.EasingStyle.Cubic.Value][poseEasingDirectionValue](a)
	end
end
1 Like