Is there any way I can use instance names to cover property names on tweens?

Basically im looping through a folder of value instances with color3 and number values for a fog tweening function. Im using for i,v in pairs cause thats what im use to doing + it feels easier to modify. When i try using v.Name I get the error "TweenService:Create no property named ‘name’ for object ‘Atmosphere’ ". Is there any idea how to fix this? If you do then please say so. Thanks in advance!


for i,v in pairs(game.Lighting.StormTween:GetChildren()) do
			local name = v.Name
			local val = v.Value
			game:GetService("TweenService"):Create(game.Lighting.Atmosphere,,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out,0,false,0),{name = val}):Play()

StormTween Folder contents:

1 Like

Need to use square brackets when defining a dict’s index to allow for a variable index.
[name] = val

Doing { key = value } is the same as doing { ['key'] = value }

By the way it should be faster to just add each prop to a table and create a single tween and play it that way.

local props = {}

for _, child in do
    props[child.Name] = child.Value

tweenService:Create(, tweenInfo, props):Play()
1 Like

This works. Thanks! I realized it would be easier to do it the way you suggested but I still made the question incase this may come in handy one day. Thanks again.

1 Like

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