Getting Vector3 using Attributes

i created this simple Tween service script inside of models, but theres an unnecessary amount of it so i had to crack down and reduce it by just parent the clone to the part then getting the Position and Size set inside the model’s attribute

but the problem is for some reason it is not getting the attributes for it and it instead got set to {0,0,0}, i believe it could be a mistype but there’s no error and i had no idea what’s missing here. The Attributes Type is Vector3

local TweenService = game:GetService("TweenService")
local Part = script.Parent

local Info = TweenInfo.new(
	0.2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	-1,
	true, 
	0) 
local Place = {Position = Vector3.new(Part:GetAttribute("Position")), Size = Vector3.new(Part:GetAttribute("Size"))}

local tween = TweenService:Create(Part, Info, Place)

tween:Play()

it would work if i put it like this, but it isn’t ideal for like 10+ models having the same script

{Position = Vector3.new(2,2,2), Size = Vector3.new(2,2,2)}

any help would be appreciated :]

I believe that you are calling Vector3.new with a vector3 as the first parameter. You shouldn’t do that, and it is causing the issue.

Just do

Position = Part:GetAttribute("Position")

same with the size one.

1 Like

The problem is that Part:GetAttribute(“Position”) will return a Vector3. This means you are effectively inputting Vector3.new(Vector3.new(x,y,z)). This returns 0,0,0.

1 Like

oof, i thought it would just be automatically inputed as an x,y,z

thanks!

No, a Vector3 is 1 thing, not 3 seperate things.

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