Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a smooth vector3 increasment?


workspace.Sound:Play()
for i = 1,221
do
	wait(1)
	workspace.Player.Position = workspace.Player.Position + Vector3.new(1,0,0)
end

3 answers

✓ Accepted answer

You can always use tween service, so in this case:

workspace.Sound:Play()
local TweenService = game:GetService("TweenService")

local Info = TweenInfo.new(
	3, -- Length
	Enum.EasingStyle.Elastic, -- Easing Style
	Enum.EasingDirection.Out, -- Easing Direction
	2, -- Times repeated
	false, -- Reverse
	0 -- Delay
)

local Goals =
{
	Position = Vector3.new() --put position here
}

local tween = TweenService:Create(workspace.Player,Info,Goals)

tween:Play()

Smoothing this function out over time will require you to reduce the wait() time and reduce the displacement. Instead of doing wait(1) you could use wait(0.01), which will make the loop appear more smooth. Likewise, you would reduce the displacement by changing the Vector3 to move in smaller increments.

I'd use TweenService as it has many settings and it's very smooth.

This discussion is preserved as it was. New answers, comments, and votes are closed.