Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How Do I Tween/Interpolate Welds?

Asked by 9 years ago

Function:

_G.Interpolation = function(Weld, FinalC1, Frames)
    local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = FinalC1:components()
    local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = (x/Frames), (y/Frames), (z/Frames), (R00/Frames), (R01/Frames), (R02/Frames), (R10/Frames), (R11/Frames), (R12/Frames), (R20/Frames), (R21/Frames), (R22/Frames)
    for i = 0, Frames, (Frames / 10) do
        local cf = CFrame.new((x * i), (y * i), (z * i), (R00 * i), (R01 * i), (R02 * i), (R10 * i), (R11 * i), (R12 * i), (R20 * i), (R21 * i), (R22 * i))
        Weld.C1 = Weld.C1:lerp(cf, i)
    end
end

Weld = the weld we are tweening/interpolating FinalC1 = Final cframe we want the weld's c1 to be at Frames = how many frames do we use to tween Script:

Interpolate(game.Workspace:WaitForChild("Goalie"):WaitForChild("Goalie"):WaitForChild("Right Arm"):WaitForChild("Weld"), CFrame.new(77.306778, -86.8971558, 122.12915, -0.0184396002, 0.525726199, -0.850447237, -0.243222177, 0.822683871, 0.513832808, 0.969787776, 0.216331556, 0.112699158), 5)

We are tweening a goalies right arm to a certain cframe so he can make a save, with 5 frames there isnt much to explain but if you could help fix the script or tell me what I did wrong I would really appreciate it, thank you ~ DevScripting

Answer this question