Skip to content

Instantly share code, notes, and snippets.

@Nimblz
Created December 2, 2019 18:47
Show Gist options
  • Save Nimblz/32b757720f5df51a94708034a1445c51 to your computer and use it in GitHub Desktop.
Save Nimblz/32b757720f5df51a94708034a1445c51 to your computer and use it in GitHub Desktop.
return function(model)
assert(model.PrimaryPart,
("%s has no primary part. Cannot create cache."):format(
model:GetFullName()
))
local root = model.PrimaryPart
local offsets = {}
for _, child in pairs(model:GetChildren()) do
if not child == root then
local offset = root.CFrame:Inverse() * child.CFrame
offsets[child] = offset
end
end
return offsets
end
return function(model, newCFrame, cache)
assert(model.PrimaryPart,
("%s has no primary part. Cannot create cache."):format(
model:GetFullName()
))
local root = model.PrimaryPart
root.CFrame = newCFrame
for part, cframe in pairs(cache) do
part.CFrame = newCFrame * cframe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment