Have you ever for some reason wanted to calculate the world position of a bone ?
Here’s is how it’s done.
local function getWorldPosition(bone)
local current = bone
local worldCFrame = bone.CFrame
--local transformation=bone.CFrame
local boneoffset=bone.CFrame
while current.Parent and current.Parent:IsA("Bone") do
current = current.Parent
worldCFrame = current.CFrame * worldCFrame
end
boneoffset=worldCFrame
if current.Parent:IsA("BasePart") then
worldCFrame = current.CFrame * worldCFrame
worldCFrame = current.Parent.CFrame * worldCFrame
end
--local change=worldCFrame
return worldCFrame.Position,boneoffset
end
Why is this useful? for realtime calculation of bones world cframes so you can place an object on the bone such as a flamethrower. It’s actually quite similar to what you would use a rigid constraint for.
To visualize what it is doing think of how a bones properties are of a cframe offset from its parent. it repeatedly checks if the parent is a bone as it continues the loop, when its not the accumulated cframe is summed to the cframe of the initial part. It matches the property of WorldCFrame that is unreadable during runtime but visible in studio.
If anyone has any questions feel free to ask.
Is this usable with animations? I think it is, but I haven’t tested it, it’s a game changer if it does.