TweenService w/ function parameter

Roblox has an existing tween service that let’s you tween almost any property. I think it’s great, but it doesn’t include a way to pass a function through the tween. I had to create my own system that let’s me tween stuff so that I could have this. What I want is the ability to pass a function as an arg and the first 2 args that go through the function are PercentTweened and TimePassed. Inside the function you can use these to code specific triggers at specific times (ex: run explosion here when more than 50% of the tween is done, then clean something up once the tween is 100% done).

Here’s the existing API

Here’s an API that almost does what I want. It lets you access the alpha of a tween w/ a tween type, but it doesn’t let you link any function or run on it’s own. TweenService | Documentation - Roblox Creator Hub

31 Likes

I use my own tweening system as well. After talking to some other devs on twitter I’m seeing that developers making their own workarounds for this isn’t that uncommon. It’d be nice if roblox could take care of something so basic as this for us.

4 Likes

This is essentially what CM32’s tween module does (as do many others I’m sure). I cannot stress how much this behavior would be preferred, as it would be far more ideal and far more useful in many more situations than current behavior. However, I see no real reason you would need to know the elapsed time since the tween began, as it doesn’t really seem useful. What use do you potentially see for this?

I’m not sure how this would be any different from RunService:BindToRenderStep or similar? I can understand callbacks added to TweenPosition and the like, but it feels like this would encourage a strange code style.