Is there was a way to tell if a Brick was tweening/fading?

Hello, I was wondering if there was a way to tell if a Brick was tweening/fading? I know this is a very short post but I genuinely don’t know.

Usually in a tween the instance property changes.

This will will fire the .Changed event multiple times for the brick for the specific property being tweened so that should work.

On a side note it’s hard to differentiate if a script is editing the property once vs a tween so just make sure of this in your code.

The only issue is, I have no idea how to go about differentiating something such as this… do you have any ideas?

Since changing a property multiple times to make a smooth transistion/movement with tweens I would detect if a property got changed multiple times over a small period of time

https://gyazo.com/8018ceb41d7504d876f2803e1d7d8ee7

script i used fot the output

local TS = game:GetService("TweenService")

local tween = TS:Create(workspace.Part, TweenInfo.new(2, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out), {CFrame = workspace.EndPart.CFrame})

local a = 0

workspace.Part:GetPropertyChangedSignal("CFrame"):Connect(function()
	a += 1
	print('event fired '..a..' times!')
end)

wait(5)

tween:Play()

Alright, so how would I differentiate if the part just changed colors once or multiple times…? Thank you for showing me the GetPropertyChangedSignal in action, I never used that.

In order to best differentiate between

part.Transparency = 1
--vs
Tween:Play()--transparency tween

Is to use an event or a signal module or bindable events.

Psuedocode:
You create a module with a signal object

local customEventsModule ={}

local partTween = Signal.new()
customEventsModule.PartTweened = partTween 

return customEventsModule 

In another script you require this signal and any time you tween something you fire the signal.

local CustomEvents = require(--path to custom events module)

--when you play a tween
Tween:Play()--transparency tween
--you also fire a signal
CustomEvents.PartTweened:Fire(part,Tween)

Then in another script you can detect or listen that this part is being tweened by using an event connection.

--in script 2
local CustomEvents = require(--path to custom events module)

--part is the part being tweened, and tween is the tweenBase itself being played
CustomEvents.PartTweened:Connect( function(part,tween)

end)

This way you can guarantee it’s a tween being played and not another script changing this property.

1 Like