How to determine if an AnimationId is R6 or R15 via script?

How to determine if an AnimationId is R6 or R15 via script?

1 Like

not 100% sure, never tried, but you could try to load the animation and see if it worked or not

--detect a rig/char R6/R15, lets say R6 for example
local RigType = "R6"

local animationTrack = humanoid:LoadAnimation(animation)
if animationTrack then --loaded, not sure if it wont load on diff type, but I assume it wouldn't
    --Animation type is rig/char type?
    print("Animation is "..RigType)
else  --Animation did not load so maybe it don't match the rig/char type??
    print("Animation is not "..RigType)
end

Why are these always so hard… (lowkey love it)
There is no way to do this directly. This may work as a workaround.

function isR15(animId)
	local assetId = tonumber(animId:match("%d+"))
	local model = game:GetService("InsertService"):LoadAsset(assetId)
	local seq = model:FindFirstChildOfClass("KeyframeSequence")
	if not seq then return nil end
	for _, kf in seq:GetKeyframes() do
		for _, evt in kf:GetChildren() do
			if evt:IsA("Pose") and evt.Name == "UpperTorso" then
				model:Destroy() return true
			end
		end
	end	model:Destroy()
	return false
end
2 Likes

it works!!!

local R15OnlyJoints = {
	"UpperTorso", "LowerTorso", "LeftUpperArm", "LeftLowerArm", "RightUpperArm", "RightLowerArm",
	"LeftUpperLeg", "LeftLowerLeg", "RightUpperLeg", "RightLowerLeg",
	"LeftHand", "RightHand", "LeftFoot", "RightFoot"
}

do -- convert to R15OnlyJoints to Dictionary
	local new = {}
	for i, v in ipairs(R15OnlyJoints) do
		new[v] = true
	end
	table.clear(R15OnlyJoints)
	R15OnlyJoints = new
end

local function IsAnimationIdR15(animationId:number)
	print("Checking",animationId)

	local success:boolean, Anim:Instance? = pcall(function()
		return game:GetService("InsertService"):LoadAsset(animationId)
	end)

	if not success then
		return
	end
	if not Anim then
		return
	end
	for _, any in ipairs(Anim:GetDescendants()) do
		local jointName = any.Name

		if R15OnlyJoints[jointName] then
			Anim:Destroy()
			return true
		end
	end

	Anim:Destroy()

	return false
end
print(IsAnimationIdR15(id))

image

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.