Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Vector3:Lerp doesn't work anymore? [closed]

Asked by
Exsius 162
9 years ago

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
0
Are you observing any errors? Are you sure that neither Pos1/Pos2 are 0? BlueTaslem 18071 — 9y
0
strange thing is there are no errors at all Exsius 162 — 9y

Locked by adark and Perci1

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
3
Answered by
Hibobb 40
9 years ago

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
print( Vector3.new( Vector3.new(1, 5, 2) )) --> 0, 0, 0. What the heck ROBLOX? Excellent catch. BlueTaslem 18071 — 9y
0
Yeah, that should definitely throw an error. I wonder if it's a hidden Vector3 constructor? adark 5487 — 9y
Ad
Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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!