What I want to happen is when a character presses 'M' then a model will slowly come up from the ground next to the character. I can do the pressing M part but I'm not sure how to move the model smoothly.
Basic lerp methods:
cframeoffset = CFrame.new() game:GetService("RunService").RenderStepped:Connect(function() cframeoffset = cframeoffset:lerp(target CFrame, alpha) --when approaching its target slows down, e.g: 0, 0.5, 0.75, 0.875 etc... cframeoffset = start CFrame:lerp(target CFrame, alpha) --travels at a steady speed, e.g: 0.1, 0.2, 0.3, 0.4 etc... end)
And to lerp the model:
local model = path.to.model game:GetService("RunService").RenderStepped:Connect(function() --method you used to set the cframe model:SetPrimaryPartCFrame(cframeoffset) end)
I hope this helps.
You can set the model's Model.PrimaryPart
property, and afterwawrds use the Model:SetPrimaryPartCFrame()
method and the CFrame:lerp()
method to do this. I'd caution you that you should weld the parts of your model to the primary part to prevent rounding errors from slowly distorting your model as it moves over time. (See here: https://devforum.roblox.com/t/setprimarypartcframe-gradually-offsets-component-parts/16041)