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

How to edit this tween code so I can tween 2 parts at once?

So I'm trying to tween 2 objects at once; a pointlight and a part. I have this code as my parts/colours and stuff;

local partProperties = {
		Color = Color3.fromRGB(255,0,0),
		light.Parent.Color = Color3.fromRGB(255,0,0)
}

when I run the code, I get the error Expected a name, got a complex expression how do I fix this?

1 comment

0

With tween service you are modifying properties of only one instance, create 2 different tween for these objects.

3 answers

So far as I know you cant modify two different parts in the same tween but you can do it with playing two tweens at the same time

It gives that error right now because it expects a name of the property you wanna change but you gave a color3 value and then assigned that to another color3 value

Color is the same as ["Color"]

You can just run the same tween on both parts.

local partProperties = {
        Color = Color3.fromRGB(255,0,0),
}
tweenService:Create(part, TweenInfo, partProperties):Play()
tweenService:Create(pointlight, TweenInfo, partProperties):Play()
-- this is assuming youve defined everything correctly

The script above is broken, try this:

local TweenService = game:GetService("TweenService") -- get the TweenService
local partProperties = {
        Color = Color3.fromRGB(255,0,0),
}
local lightProperties = {
        Color = Color3.fromRGB(255,0,0),
}
local pointLight -- define your pointlight instance here
local part -- define your basepart/part/meshpart/union here
local partTween = TweenService:Create(part, TweenInfo.new(2, Enum.EasingStyle.Linear), partProperties)
local lightTween = TweenService:Create(pointLight, TweenInfo.new(2, Enum.EasingStyle.Linear), lightProperties)
partTween:Play()
lightTween:Play()
lightTween.Completed:Wait() -- As the lightTween is last playing wait until the lightTween is finished.

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