TweenModelService - Easily tween models

Have you ever tried to tween a model, but found out you couldn’t? That is finally over. I have created something that I call TweenModelService!

Here is a quick demo of me moving a free model building:

First, add a PrimaryPart to your Model.

Then add my Module to your game.
Get as a Lua File: TweenModelService.lua (2.1 KB)
Get as a .rbxm: TweenModelService.rbxm (1.6 KB)
Get as a Free Model: TweenModelService - Roblox

I would recommend putting my Module in ReplciatedStorage, but ServerStorage and ServerScriptService are fine if you dont want to tween models on the Client.

Once you have my module all set up, write this line of code:

local TweenModelService = require(game:GetService("ReplicatedStorage").TweenModelService)

You then can treat it exactly like you would with TweenService.

I created this example place here:
ExamplePlace.rbxl (41.1 KB)

Documentation

TweenModelService

Functions:

:Create(Model, TweenInfo, Dictionary) (ModelTween)

Creates a new ModelTween given the Model whose properties are to be tweened, a TweenInfo and a dictionary of goal property values.

ModelTween:

Properties:

Welds (Array):

An array of WeldConstraints that TweenModelService:Create() uses to make the Tween work.

Functions:


Events:

How does it work?

It welds every part together with WeldConstraints to the PrimaryPart, and moves the PrimaryPart to the goal. Once ModelTween:Destroy() is called, it will clean up the welds for you.

Let me know what you think, or if you found this useful, or if you have an update request.

16 Likes

This is (somewhat) of a clanky way for animating models. I’d actually recommend using AnimationControllers when possible because they’re both pre-baked and already host internal replication

Of course, when that’s not a viable option or you just don’t want to deal with dumb Roblox bugs this module is very well-made for what it’s worth. Good job!

4 Likes

I appreciate the effort, but why would you use an outdated approach? Instead of using welds, just set the pivot of the model using model:PivotTo(cFrame).

1 Like

Using Model:PivotTo() in a loop makes it choppy and not as smooth as this.

1 Like

That’s strange, I’ve never experienced that. Perhaps try setting the network owner to nil? (The server)

Have you tried this approach?

local TweenService = game:GetService("TweenService")

local function TweenPivotTo(model, target: CFrame, tweenInfo: TweenInfo)
	local cframeValue = Instance.new("CFrameValue")
	cframeValue.Value = model:GetPivot()
	cframeValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:PivotTo(cframeValue.Value)
	end)
	
	local tween = TweenService:Create(cframeValue, tweenInfo, {
		Value = target
	})
	tween.Completed:Connect(function()
		cframeValue:Destroy()
	end)
	tween:Play()
end

I’m not sure that’s correct. I made a module for tweening PVInstances based on their Pivot points before, and it ended up smooth no matter the framerate. My solution was to use a ghost part, tween that, and then call PVInstance:PivotTo(ghostPart.CFrame) every frame.

It’s far from optimal, but it worked smoothly and consistently, even on clients with unlocked framerates.

Isn’t this just the same as TweenService? You are still asking for the tween info, and have the exact same functions. It’s not easier in any way to use this.

It’s not meant to be easier to use than TweenService. It’s meant for tweening models - which have no properties TweenService can directly interact with.

It uses TweenServive, but it moves models. You can’t move models with TweenService alone.