Is it possible to add a time to SetPrimaryPartCFrame?

  • Hi people! :D

    I want to move a model from it's original position to the goal I set, but take time to get there. Let's say I want it to take 5 seconds (any time is fine) to get there. I would use tweening, but I'm moving a model if you noticed that I used a function from a Model. I would use tweening, but it doesn't work with models and I just want to stick with using SetPrimaryPartCFrame function. If you don't know what that is, SetPrimaryPartCFrame is a simple function that uses CFrame to move a model. (I know I could also use the :MoveTo function, but that's for moving the primary part and only the primary part) So my question is how could I possibly add a time that it takes for a model to get from the starting position to the end?

  • CFrame:lerp()

    Simple example:

    function primaryPartLerp(model, endCFrame, duration)
    	local startCF = model.PrimaryPart.CFrame
    	for i = 1, duration / .2 do
    		local alpha = i / duration	
    		model:SetPrimaryPartCFrame(startCF:lerp(endCFrame, alpha))
Log in to reply

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.