Might be missing something.. ( Vector3 )

Yo, so this code doesn’t work

local Book = script.Parent local TS = game:GetService("TweenService") local TI = TweenInfo.new(4,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true) local goal = {} goal.Position = Book.Position.Y + 3 -- the problem is here local tween = TS:Create(Book,TI,goal) tween:Play()

But this one does

local Book = script.Parent local TS = game:GetService("TweenService") local TI = TweenInfo.new(4,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,-1,true, 0) local goal = {} goal.Position = Vector3.new(Book.Position.X, Book.Position.Y + 4, Book.Position.Z) local tween = TS:Create(Book,TI,goal) tween:Play()

So why didn’t Book.Position.Y work even though its dealing with vector3? Thanks.

2 Likes

This is because you are adding together a Vector3 and a number which isn’t possible. On the second script, you are adding two Vector3s which is valid.

2 Likes

Sorry, my post was a bit messed up. You’re trying to set a Vector3 property as a number which isn’t possible. For the second case, you are setting a Vector3 property as a Vector3, which obviously is possible

Book.Position.Y is a number, while Vector3.new(Book.Position.X, Book.Position.Y + 4, Book.Position.Z) is a Vector3.

Ignore my other post, it’s wrong

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.