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

how to slide vector3 point1 to vector3 point2 on line?

I don't really need the sliding itself but to get the point2 on the line which is .2 studs far from point1, so I wrote this code:

local Pos2 = Vector3.new(Pos1 + (Direction.unit * .2))

where Direction is lookVector, so I need Pos2 to be on Direction line .2 studs far away from Pos1 but in the code above the output returns Pos2 as (0,0,0)

1 answer

Use TweenService for this:

local TweenService = game:GetService("TweenService")
 
local part = workspace.Part -- The object
 
local goal = {}
goal.Position = Vector3.new(10, 10, 0) -- Position
 
local tweenInfo = TweenInfo.new(5) -- Time in seconds it will take
 
local tween = TweenService:Create(part, tweenInfo, goal)
 
tween:Play()

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