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

Can someone help with this model "tween" script?

Asked by 10 years ago

I made a tweening script, but its not working. It throws no errors yet does nothing. and dosnt print this stuff. Help?

function TweenCFrame(Model,newCFrame,step,UwantDelay) 
    tweeningfunction = function ()
        TheCF = Model:GetModelCFrame()
        local OldP = TheCF.p 
        local oldAngle = Vector3.new(TheCF:toEulerAnglesXYZ()) 
        local NewP = newCFrame.p 
        local newAngle = Vector3.new(newCFrame:toEulerAnglesXYZ()) 
        print("OldP = "..OldP)
        print("oldangle = "..oldAngle)
        print("NewP =  "..NewP)
        print("NewAngle = "..oldAngle)
        print("NewAngle = "..newAngle)
        local Repeater = coroutine.create(function() 
            for i = 0, 1, step do 
                Model:MoveTo(((OldP*(1-i))+(NewP*i))*CFrame.fromEulerAnglesXYZ((oldAngle.x*(1-i))+(newAngle.x*i),(oldAngle.y*(1-i))+(newAngle.y*i),(oldAngle.z*(1-i))+(newAngle.z*i)))
                wait() 
            end 
            TheCF = newCFrame 
        end) 
        coroutine.resume(Repeater) 
    end
    if UwantDelay == true then
        delay(0,tweeningfunction)
    else
        pcall(tweeningfunction)
    end
end

Thanks.

0
Did you ever call the function? For example: TweenCFrame(Car, CFrame.new(0, 0,0), 20, false)? BlackJPI 2658 — 10y

Answer this question