TweenService V2

If I was to tween a SpotLight in its range, is it still possible to get it as smooth as if it was on the server.
I’m struggling to make it smooth using the module.

1 Like

Theoretically this should be more smooth than server side tweening in some cases, could you send your code?

2 Likes

Are we able to use the .Completed Event with this module?

2 Likes

Hi, no this isn’t part of the module. I might add it in future , didn’t think about it when making it since I rarely use this property myselfm

These changes are definitely useful!

I am not sure this is working properly. I followed the setup in the video but i get an error:

this seems to be because the module is trying to create a RemoteEvent but it never gets created and the client then hangs up when the WaitForChild cannot happen

These are the first lines of code in this module that should be doing that, but they dont do it.

local module = {}
local tService = game:GetService("TweenService")
local rService = game:GetService("RunService")
local tEvent

if tEvent == nil and rService:IsServer() then
	tEvent = Instance.new("RemoteEvent", script)
	tEvent.Name = "TweenEvent"
else
	tEvent = script:WaitForChild("TweenEvent")
end

Anyone know why this wouldn’t work as it says it should? The code looks good to me, why wouldnt the RemoteEvent be created?

Are you calling the module both client and server side?

1 Like

I definitely was. The error is from the client not finding the event when doing the waitforchild.

When running I studio, the server-side module never creates the event. I checked and it isn’t there during test, hence the error being thrown from the client side.

Sorry I can’t test further, I have since removed the code.

1 Like

This is a really cool module.
I might use it for my RPG game, however, I have an hypothetical scenario that I’m curious about.

To explain this scenario, I have drawn this highly detailed comic:


Basically, a red guy throws a fireball spell and a green guy protects himself with a shield spell.

The collision itself would be detected on the server side and the tween would have to stop mid-way before reaching the target.

What happens if the client side lags and doesn’t get the memo to pause?
When it eventually receives the message to pause, does the fireball rewind itself back before pausing, or does it just freeze where it is?

1 Like

The module is essentially a proxy for clientside tweens, so the behaviour here would be the same as it would be were you to send your own event to the client which then triggered the tween on the client. I don’t think you are doing this here, but make sure not to use the module for any kind of competitive game mechanics, due to the latency problems you mentioned.

The module doesn’t have a fail-safe to make sure that the client has received the event, so I suppose in edge cases with very bad internet the tween could continue without being paused.

1 Like

I hate necrobumping topics, but I have a question. Is there a way to wait for the tween to finish on the server? Is there some kind of event that I have to wait for in order to know when the tween is finished?

1 Like

Any chance you’re planning on adding this? I personally find .Completed really useful as I often make things happen after the tween ends and check the PlaybackState, although I’m not sure how you’d implement this as the tweens finish at different times.

2 Likes

That’s something .Completed would be useful for (you could for example do Tween.Completed:Wait()), but the module sadly doesn’t have this so I’m not sure if it’s possible at all. If you do find/have found a way though, please let me know as I’m currently trying to do the same.

1 Like

Looks absolutely awesome, look forward to trying it out. It seems extremely easy to use!

Get an error when trying to pass a player object in Play
Unable to cast value to Object
On line 100

tEvent:FireClient("RunTween", instance, tInfo, propertyTable) -- play tween for specific player

I thought maybe adding specificClient to the FireClient would work, which I believed it did, but it also ended up causing the tween to play on the server as well (well the object would like teleport a few studs, pause for a second, teleport few studs more, stop, continously)

So I don’t know how to fix that

1 Like

if anyone else is having the same issue, a simple solution would be to add a RemoteEvent under the script manually and reference that instead.

local Event = script.TweenEvent   --//
1 Like

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