TweenService V2

This is awesome! Thanks, I’ll add this to the original post

1 Like

Has anyone tried to to use this for a Zombie type game with some custom NPCs? I wonder how efficient this module would remain if you recalculated path finding every 1 second for the zombies?

Hey @SteadyOn!
I believe I found a bug/error:
Stop is not a valid member of Tween "Tween"
In the script: (line 217)

As far as I know, :Stop() isn’t a function in tweenService. Should this be replaced with :Cancel()?

Other than that, very thankful for you sharing this great module with us!

Edit:
I tried changing :Stop() with :Cancel() and it somewhat works. However, since the module interprets it as the animation finishing it automatically re-assigns the parts position to it’s pre-defined end position.

As in: I cancel the animation, and then it automatically (On the server, and hence, all clients) teleports to it’s end position INSTEAD of staying where it was cancelled.

Is there any thing I am doing wrong? Or is there any way to let the part stay when cancelled, and NOT be teleported to the end position that was defined in the tweenInfo? PS: This is when changing the :Stop() to :Cancel()

Thanks!

Do you have plans of trying to create a function like TweenService:TweenModel()? I’m having a hard time tweeting models and keeping all of the same axis.

I’ve tried for _, item in pairs(Item.Door1:GetChildren() do and it keeps on moving all of the axis and not just the 1 I want.

Someone else here already made it!

Just set any part of the model as a PrimaryPart (preferably part at center) and then tween it’s CFrame.

TweenService:Create(Model.PrimaryPart, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(0, 20, 0))})

PrimaryPart is a property of Model btw

Is there any way to find when a tween ends using this module?

Hmm this is weird, maybe it was added in one of the commits I approved, will try to check it out when I have the time!

1 Like

Thank you! I appreciate you taking the time to fix this. While you’re at it, I found another bug (I believe):

So the problem is that I keep getting the error Tween being paused does not exist. when trying to pause tweens using remote events.

Doing:

tween:Play()
wait(2)
tween:Pause()

works great, but when I do something like this:

startEvent.OnServerEvent:Connect(function()
	tween:Play()
end)

pauseEvent.OnServerEvent:Connect(function()
	print("Pausing tween!")
	tween:Pause() 
end)

It starts the tween, when trying to stop it, I get the error: Tween being paused does not exist.

I am not sure why this happens, I’ve looked at the code and tried to debug some. But it seems like the tween for some reason doesn’t get saved in the module (also in earlier lines than when the warning is printed).

By the way, for some reason it works if both :Pause() and :Play() is in the same event:

startEvent.OnServerEvent:Connect(function()

tween:Play()

wait(2)

tween:Pause()

end)

I’ve talked with some other users who use this module, and they have the same issue. It would be nice if you could take a look at that also, since it working with remote events is quite important for many!

Thanks again!

Would you mind DMing me the whole script? Or just the relevant parts if it’s huge. Just want to figure out whether this is a module issue or a use case I didn’t consider.

1 Like

I’ll be able to send it tomorrow, first thing. I currently don’t have access to my PC. Thanks for taking a look at it! :slight_smile:

Edit: I’ve sent you a PM!

Hi, sorry for bumping this topic. But did you receive my DM?

Yeah that can be usefull, you think to add it?

Hey, I do have a problem with it and I’m not sure why its not working. The script doesn’t error but the tween isn’t playing either.

			TweenModule:Create(Floors.Floor1.Doors.DoorL.DoorL.PrimaryPart, TweenInfo.new(DoorOpenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = Floors.Floor1.Doors.DoorL.Org.CFrame}):Play()

Thanks if you can help.

I would suggest you use TweenService+, which is basically an upgraded TweenServiceV2

I’m using this module for a long time and it helps me with replicating it easily, what I got today is this bizarre looking bug while i was about to animate my weapons but when i opened blender plugins and selected character, script runs but doesn’t stop even after stopped playing the game.

Tween still works but it’s somehow inaccurate when i played the game (client doesn’t run tween loops but does on serverside)

do note there’s no edit being made, this is a raw video

1 Like

What a coincidence, I made a script that uses this exact idea to tween parts for my tycoon buildings. The first time I implemented and tested it, I was blown away at how phenomenal the lag reduction was when tweening on the client and verifying CFrame on the server! Damn, and I thought I was unique…

1 Like

has been ~4 years and i still cant wait for the completed event.

Hi
I found putting a simple check if the instance is replicated works:

if not instance then
   return
end

This should be placed under the ‘OnClientEvent’. This way the client doesn’t tween the object. But once the server sets the property and the client streams the part back in again, the property will be streamed correctly to that client.

Warning: Smooth tweens for a client will only be applied if the instance is streamed in on that client before creating the tween on the server!

So if the client streams the object in while it is being tweened, it will see the property being instantly set on tween finish. This is however a minor issue in most cases, and most likely not noticeable for short tweens.

I made a pull request for this check ~8 months ago which has fortunately just been merged. If you get the module straight from GitHub, adding this patch manually is no longer necessary.

1 Like