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

"Tweening" a Vector3? (Fading between two Vector3s)

So my question is this: What's the best way to "Tween" a Vector3? I know you can't actually Tween it, what I mean by that is what is the best way to take a Vector3, and then fade it into another one?

(e.g. [0,0,0] - [1,0,5], The value wouldn't just go strait to [1,0,5], it would fade at a set rate (speed). e.g. [0,0,0]-[0.2,0,1]-[0.4,0,2]-[0.6,0,3]-[0.8,0,4]-[1,0,5])

Here's some code I made that kinda works:

local Def_Offset =Vector3.new(0,0,0)
local Offset0 =Vector3.new(-0.52,0.25,0.5)

local FadeX =false
local FadeY =false
local FadeZ =false
while FadeX ==false or FadeY ==false or FadeZ ==false do
	if tool.Value.Offset.Value.X <Offset0.X then
		tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0.01,0,0)
	elseif tool.Value.Offset.Value.X >Offset0.X then
		tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0.01,0,0)
	else
		FadeX =true
	end
	if tool.Value.Offset.Value.Y <Offset0.Y then
		tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0,0.01,0)
	elseif tool.Value.Offset.Value.Y >Offset0.Y then
		tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0,0.01,0)
	else
		FadeY =true
	end
	if tool.Value.Offset.Value.Z <Offset0.Z then
		tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0,0,0.01)
	elseif tool.Value.Offset.Value.Z >Offset0.Z then
		tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0,0,0.01)
	else
		FadeZ =true
	end
	wait()
end
print("Done!")
tool.Value.Offset.Value =Offset0

It dose fade, but it never stops fading, just moves back and forth at the end. Also, I'd need to be able to change how much it adds to the value, but still get the end Vector3. (to make it fade faster/slower)

I tried some weird division solution, but that went horribly wrong, so here I am. Thanks for your time.

2 comments

0

Oh... You can Tween Vector3. Thanks for your help.

1 answer

So, uh. Apparently you CAN Tween Vector3s... My bad, Sorry everyone.

2 comments

0

@mbramblet you can also tween CFrames.

0

Ya, I've seen the entire list. You can Tween all sorts of stuff now! Guess I should've looked into it a little more before asking.

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