TweenService V2

This is really neat! It didn’t quite fit my use case where I wanted to tween a model’s position, so I edited the script a bit to accept SetPrimaryPartCFrame as a property name with a CFrame value. I haven’t tested it rigorously, so I don’t know how well it behaves under stress or when other properties are included in the table, so user beware. Still gonna drop it here in case anyone wants it:

ReplicatedTweeningWithSetPrimaryPartCFrameAndUnnecessarilyLongFileName.rbxm (5.4 KB)

Thanks for the cool module, may your tweens be buttery smooth!

5 Likes

How would I go about using this for doors? I already have a door system which used the regular tweenservice but I switched to this for smoother tweening. It works very well in studio (and most of the time in-game) however I have been experiencing an issue in-game where sometimes the door’s tween does not play on the client side - and so you just see it jump right to the end position.
Currently, what I’m doing is defining the tween with :GetTweenObject() as a local variable. I then play that tween on the server and then fire the tween object to all cllients through a RemoteEvent in ReplicatedStorage and then when the client recieves it, it will play the tween object it receives. It works for the most part however I get this error:

image

Here’s my code:

--SERVER (tween part only):
local TS = require(game.ReplicatedStorage.ReplicatedTweening)
local Tweener = game.ReplicatedStorage.Tweener

local door = script.Parent.door

local info = TweenInfo.new(1.4,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local Table = {Position = door.Position + Vector3.new(0,10,0)}

local tween = TS:GetTweenObject(door, info, Table)

tween:Play()
Tweener:FireAllClients(tween)

--CLIENT:
local Tweener = game.ReplicatedStorage.Tweener

Tweener.OnClientEvent:Connect(function(tween)
    tween:Play()
end)


Is there a better way to do this? Thanks.

EDIT: By the way the line 68 error looks like this:

Tweener.OnClientEvent:Connect(function(tween) --line 67
    tween:Play() --line 68
end) --line 69

image
My guy, I’m experiencing a bug that shouldn’t be possible.

1 Like

Doesnt seem ot be working for me :confused:
Heres the code:

local TweenService = require(game.ReplicatedStorage.ReplicatedTweening)
local model = script.Parent.Door.PrimaryPart
local db = false

local Info1 = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Quad, 
	Enum.EasingDirection.Out, 
	0, 
	false, 
	0 
)

local Goals1 =
{
CFrame = script.Parent.Closed.CFrame
}

local Info2 = TweenInfo.new(
	0.5, 
	Enum.EasingStyle.Sine, 
	Enum.EasingDirection.Out, 
	0, 
	false, 
	0 
)

local Goals2 =
{
CFrame = script.Parent.Open.CFrame
}

local open = TweenService:GetTweenObject(model, Info1, Goals2)
local close = TweenService:GetTweenObject(model, Info2, Goals1)

script.Parent.DButton.ClickDetector.MouseClick:Connect(function()
		if not db then
				db = true
				script.Parent.Close.Value = not script.Parent.Close.Value
				wait(.6)
				db = false


		
	end
end)

script.Parent.Close.Changed:Connect(function()
	model.Move:Play()
	if script.Parent.Close.Value == true then -- close door
		close:Play()

	else -- open door
		open:Play()

	end
end)

It doesnt tween, it just teleports the part after the tween is done

EDIT: Not even the example code works, please fix ://

3 Likes

Yeah, I think this module is broken right now. This was happening to me maybe a month or more ago and I’m surprised this big of an issue hasn’t been fixed yet. I’m pretty sure the creator knows about it though, and I think he’s gonna fix it (don’t know when though)

I can’t seem to tween an model’s primary part where the primary part contains welds to every other part in the model. It just tweens the primary part, oddly enough the welds remain even though every other parts stay in palce. What may I do to fix this up?

Can you add a Completed event to your custom Tween object?

10/10 Simple and clear to use! :smiley:

Really? It doesn’t work for me.

Really ? Are you using the model place ? If so, please go to the github that he’s posted and copy & paste the raw source code. Maybe the old place is outdated :slight_smile:

Seemed to be buggy but I rescripted it so it’s fine now.

Either this bug hasn’t been fixed yet or it’s back. image

1 Like

Thank you for this module I have managed to get it to work but regarding looping infinity how can that be implemented?

Thank you for creating this.

You’d think Roblox would already have TweenService replicating the Tween for the client to handle, guess not.

Can you add a Completed event to your custom Tween object?

Preferably I would like this too - I use .Completed on tweens a lot so this will help quite a bit if .Completed is added. If possible that is.

Are there examples of the server and client code required to use?

Regards

This tutorial that @SteadyOn uploaded should do the trick. TweenService V2 | Roblox Scripting Tutorial 📜📜 - YouTube

I’m not exactly sure if this is possible, as the way this module was coded was that the actual tweening was done on the client as opposed to the server. You could hard-code something similar to it and check if the duration of the tween has passed since it started to check if it is done. For :Cancel() and other stuff you could hard-code that.

1 Like

Is this meant to be used so " :GetTweenObject()" can only be called in the server and not in the client?

The line

latestFinish[instance] = latestFinish[instance] or os.time() -- cannot be nil.

will error nil I believe because of streaming enabled.

Hi,

The TwwenService works well for me but would like to see a way for getting the part to face the way of the tween as an option?