Adding variables in tween params

-- error: TweenService:Create no property named 'property' for object 'ReadTime' 

local function tweenFunc(object, property, value, tweenTime)
   local tween = game:GetService("TweenService"):Create(object, TweenInfo.new(tweenTime), {property = value}):Play()
end

can someone tell me why i cant use variables to fill in tween params and what alternatives there are that i can use

Do this instead:

local function tweenFunc(object, goal, tweenTime)
   local tween = game:GetService("TweenService"):Create(object, TweenInfo.new(tweenTime), goal):Play()
end

tweenFunc(Part, {Transparency = 0.5}, 2) --// Example
1 Like

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