Created
December 2, 2019 18:47
-
-
Save Nimblz/32b757720f5df51a94708034a1445c51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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