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

Vector3:Lerp doesn't work anymore?

it just makes the Target go to (0,0,0)

This is strange I'm pretty sure I'm doing it right.

All the names are correct no misspelling.

		local Pos1 = Vector3.new(script.Parent.Posi1.CFrame.p)
		local Pos2 = Vector3.new(script.Parent.Posi2.CFrame.p)
		local Brick = script.Parent.Target

		for ratio = 0,1,0.1 do
			local NewPosition = Pos1:lerp(Pos2, ratio)
			Brick.Position = NewPosition
			wait()
		end

2 comments

0

Are you observing any errors? Are you sure that neither Pos1/Pos2 are 0?

0

strange thing is there are no errors at all

2 answers

I believe this is your problem :

Vector3.new(script.Parent.Posi1.CFrame.p)

Essentially what you are doing is Vector3.new(Vector3.new()). CFrame.p is already a Vector3. Try doing this:

local Pos1 = script.Parent.Posi1.CFrame.p
local Pos2 = script.Parent.Posi2.CFrame.p
local Brick = script.Parent.Target

for ratio = 0,1,0.1 do
    local NewPosition = Pos1:lerp(Pos2, ratio)
    Brick.Position = NewPosition
    wait()
end

2 comments

2

print( Vector3.new( Vector3.new(1, 5, 2) )) --> 0, 0, 0. What the heck ROBLOX? Excellent catch.

0

Yeah, that should definitely throw an error. I wonder if it's a hidden Vector3 constructor?

You question has already been answered, script.Parent.Posi1.CFrame.p is already a Vector3, so wrapping it in Vector3.new() is unnecessary.

Further testing indicates that Vector3.new() completely ignores non-Number arguments. What's strange is that it will use them as placeholders:

Vector3.new(false, "bool", 152) --> 0, 0, 152
Vector3.new(true, 14) --> 0, 14, 0
Vector3.new(15, Instance.new("Part"), 28) --> 15, 0, 28

This is in line with Vector3 actually having four constructors:

Vector3.new() --> 0, 0, 0
Vector3.new(x) --> x, 0, 0
Vector3.new(x, y) --> x, y, 0
Vector3.new(x, y, z) --> x, y, z

This is definitely a ROBLOX bug, thank you for finding it, Exsius!

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