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

Tweening working with Vector3, but not CFrame?

Asked by 6 years ago

So I made myself a custom part tweening engine. Which works (for the most part), but I want to get it to work with CFrame so the block can clip through objects, however, I can't seem to make it CFrame comaptible, It'll keep returning errors like "CFrame expected, got Vector3" or "Got Table" etc, etc.

This is the script.

local parttomove = script.Parent
local parttomoveto = script.Parent.Parent.pto

function move()
    local tar = parttomoveto.Position
    local cur = parttomove.Position

    for i = 1,100 do
        wait()
        parttomove.Position = cur + (tar-cur) * 0.1
        cur = parttomove.Position
    end
end


script.Parent.ClickDetector.MouseClick:connect(move)
1
You are literally doing parttomove.Position, not parttomove.CFrame..... hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
NubgIe 15
6 years ago

CFrames don't support + and - operators, only * which is adding two cframes together, not multiplying if you didn't know. If you don't care about rotation, you could just do parttomove.CFrame = CFrame.new(v3) If you do want rotations included with the lerp, just use CFrame:lerp(target, alpha)

Ad

Answer this question