Documentation for TweenService SmoothDamp

The docs don’t seem to describe the return value for TweenService SmoothDamp, only “Returns a value that allows…”.

SmoothDamp(currentPosition: any, target: any, velocity: any, smoothTime: number, maxSpeed: number?, dt: number?): (newPosition: any, newVelocity: any)

It returns the new position, velocity of a spring at the given current position, velocity after the given dt has passed. The current position is the first argument and the current velocity is the third argument.

local p = 0;
local v = 0;
local DURATION = 4;
local DT = 1/60;
  for i = 1, (DURATION/DT) do
  p, v = game.TweenService:SmoothDamp(p, 4, v, 1, math.huge, DT);
  print(p, v);
end

The default values for maxSpeed and dt are also missing.

Page URL: https://create.roblox.com/docs/reference/engine/classes/TweenService#SmoothDamp

It looks to me that the return value is a tuple of only two values: the new position, and the new velocity calculated from the operation.

It also appears that while the default value for maxSpeed is indeed math.huge like in your script, the default value for dt is the framerate for the context which TweenService:SmoothDamp is running in, giving variable values between the server and client.

I don’t have permission to change set default variables, so I’ll include that in a comment alongside a link to your post here for credit.

I’ll make the above changes to the documentation alongside some better language to explain the method further. Here’s my pull request: Update TweenService.yaml by sammygrey · Pull Request #1000 · Roblox/creator-docs · GitHub

Also, in the future feel free to make any necessary changes to the documentation as it’s open sourced. I’m sure Ignis and the other devs would love for as many people as possible to contribute.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.