Optimizing TweenService

I have a system similar to the game Steal A Brainrot and I’m cloning a model into the workspace and tweening it but this spikes Network Sent and recieved to +80kb/s which is really slow for me.

I’ve tried to make the client do the tweening work but that would make it very out-of-sync and break the system since there’s also a ProximityPrompt on the part…

Any ideas or help is appreciated, thanks.

local newCat = cloneCat()
tweenCat:Fire(newCat)
		
--local newTween = tweenService:Create(newCat.PrimaryPart, tweenInfo, goal)
--newTween:Play()
--newTween.Completed:Connect(function() USED Completed instead of :Wait() since it yields the entire script
--	newCat:Destroy()
--end) 
1 Like

Client-side is the way to go. Fixing your desync issue is the real problem here. If it’s a timing issue, you can use workspace:GetServerTimeNow() on the client to get a consistent time measurement across all clients.

1 Like

I’m not sure how I would implement this to the client? There’s also a proximityPrompt which I believe only works on ServerScripts so there’s that

heres what i got: youre trying to make a tweening animation for cloning a model

my solution: use one singular part and weld it to everything in the model, then tween that one part, it’ll still be laggy but less laggy. i used this solution in one of my games, and lemme tell ya its a good solution :+1:

edit: realized that youre using a primarypart oops

can you not just use RemoteEvents to tell the client when it is being Cloned, and do all of the cloning and tweening on the client?

The debris service exists specifically for this purpose. To destroy an instance after a defined time, which avoid using workaround such as yielding the script with a wait time, implementing a connection, or using a new thread.

Like I said, it’ll make it out-of-sync across the players and make the ProximityPrompt unable to work. New players also wouldn’t see any of them going across the map

Here’s a video by Suphi

Watched most of it and it goes over what you want to do at I think 13:00, somewhere near the middle of the video I guess.

I thought tweens were automatically destroyed after being completed. It doesn’t seem that Roblox would make tweens stay after being completed, considering they had to think out every service they made. Infact, the completed event might actually just cause a little more use.

Though, I may be wrong. If you reference the tween, it might be staying. If there is no reference or if it is not in a table, it may not be destroyed. But I’m not sure and I remember that tweens were destroyed after playing.

1 Like

they do get deleted, they stay for like 30 secs and it’s ~20 instances running at once

1 Like

I’ve decided to make the prompt’s triggered function on the client-side instead and just ignored the out-of-sync issues since it won’t be much of a problem unless a player is at ~300 ping

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.