Lerp a model (cframe)

How do I lerp multiple parts, in a model. I don’t know how, just need it so go sideways slowly.

local LaunchButton = script.Parent.Click
local Missle = game.Workspace.Missle
local MissleFire = game.Workspace.Missle.Flame.Fire
local MissleSmoke = game.Workspace.Missle.Flame.Smoke

local AfterSmoke = game.Workspace.AfterSmoke.Smoke
local Platform = game.Workspace.Hatch
local Player = game.Players.LocalPlayer

local current = os.clock()

LaunchButton.MouseClick:Connect(function() 
	if os.clock() >= current then 
		current = os.clock() + 500
		print("Timer Set")
		Platform:SetPrimaryPartCFrame(CFrame.new(-9.953, 1.144, -25.625))
		wait(15)
		Platform:SetPrimaryPartCFrame(CFrame.new(-18.741, 1.144, -25.625))
	end
end)

2 Likes

My last post was different so I deleted it anyways here’s the code:

LaunchButton.MouseClick:Connect(function() 
	if os.clock() >= current then 
		current = os.clock() + 500
		print("Timer Set")
		Platform:SetPrimaryPartCFrame(CFrame.new(-9.953, 1.144, -25.625))
        wait(1)
		Platform:SetPrimaryPartCFrame(Platform:GetPrimaryPartCFrame():Lerp((CFrame.new(-18.741, 1.144, -25.625),15))
	end
end)
2 Likes

I can’t write out the code for you, but here’s an idea.

You can use tween service for this. Use tween service on a cframe value object, run the tween, and listen to the property changed signal. The cframe value is being tweened, but you can transfer this to the model. As the cframe object is changed, just update the model’s cframe to match what the cframe value object is. Make sure the value of the cframe value object is set to the cframe of the door first, presumably the primary part, before you run the tween.

1 Like

Doesnt work, needs to be in a for loop I think

I have some trouble with it, can you help me?

The lerp formula is min+(max-min)*t

The domain of t is [0, 1]

So using this for loop its cframe where the min is the end cframe and the max is the start cframe and t is a linear incrementing value from 0 to 1

for i = 0 , 1,  0.0001 do
		wait()
		Platform.PrimaryPart.CFrame  = Platform.PrimaryPart.CFrame:Lerp(CFrame.new(-9.953, 1.144, -25.625), i)
	end	
	for i = 0 , 1,  0.1 do
		wait()
		Missle.PrimaryPart.CFrame  = Missle.PrimaryPart.CFrame:Lerp(CFrame.new(-18.642, 743.625, -25.868), i)
	end    
end

end)

only the top cframe works
not the bottom

You didnt do what i told you to do though