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

Tweening working with Vector3, but not CFrame?

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 comment

1

You are literally doing parttomove.Position, not parttomove.CFrame.....

1 answer

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)

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