I attempt to pack a table with the cframe using the methods other people posted. Still doesn’t work, not sure why but the error is the following;
ReplicatedFirst.Animating:26: attempt to call a table value
Here’s the code, had some ppl review it and they said it looks correct.
local TweenService = game:GetService('TweenService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Remote = ReplicatedStorage:WaitForChild('AnimationsHandler')
Remote.OnClientEvent:Connect(function(Item, Choice, OtherChoice)
if Choice == 'Build' then
local OriginalCFrames = {}
local OriginalCollisions = {}
for _, Descendant in pairs(Item:GetDescendants()) do
if Descendant and Descendant:IsA 'BasePart' then
OriginalCFrames[Descendant] = { Descendant.CFrame:GetComponents() }
if Descendant.CanCollide then table.insert(OriginalCollisions, Descendant) end
local offestX, offsetY, offsetZ = math.random(-100,100), math.random(-100,100), math.random(-100,100)
local angleX, angleY, angleZ = math.rad(math.random(0,360)), math.rad(math.random(0,360)), math.rad(math.random(0,360))
Descendant.CanCollide = false
Descendant.CFrame = CFrame.new(Descendant.Position.X * offestX, Descendant.Position.Y * offsetY, Descendant.Position.Z * offsetZ) * CFrame.Angles(angleX, angleY, angleZ)
end
end
for _, Descendant in pairs(Item:GetDescendants()) do
if Descendant and Descendant:IsA 'BasePart' and OriginalCFrames[Descendant] then
local OriginalCFrame = CFrame.new(table.unpack(OriginalCFrames[Descendant]))
TweenService:Create(Descendant, TweenInfo(1, Enum.EasingStyle.Elastic, Enum.EasingStyle.Linear), {CFrame = OriginalCFrame}):Play()
task.spawn(function()
task.wait(1)
if table.find(OriginalCollisions, Descendant) then
Descendant.CanCollide = true
end
end)
end
end
end
end)```