Trouble making tween on client

Hello
I want to make a tween on the client that moves a basepart for all clients. I got it working on a serverScript (in the workspace), but it is really laggy for mobile players. I think due to less internet speed, So now I want to make it so that the part which is in the workspace tweens locally on the clients. Or maybe I can try something else? It is important that the part moves as smoothly as possible, because it’s a parkour/kill brick. I’m still new to scripting…
Thanks for any help!

Set up a localscript that listens to a remote event. Have the remote event send as parameter the part that it wants to tween. Then perform the tween locally.

Whenever you want the tween to happen just FireAllClients from the server script.

thanks for your quick reply, but I have alot of parts that I need to tween (moving lasers). Would I need to make remote events for all those parts? And serverscripts / localscripts to go with them? Because the lasers all move differently and they have different positions.

what you can do is move all of your server script(s) into a localscript (make the tweaks as needed such that it doesn’t break) and then just have the localscript trigger all the tweens at once when it gets an event from the server.

Of course this works only if the tweens are all part of ONE animation. If you want them to tween separately based on different events then yes the only way is to make an event for each one OR have one event in which you give all the necessary parameters for the tween (part, duration, goal, etc) and then rebuild the tween locally.

Any way you decide to do it, you should know that it is a great improvement overall because it will relieve the server of the tweening and the clients will all see very smooth transitions. All in all, it is worth the extra work.

You really only need 1 localscript and 1 RemoteEvent for this.

When using :FireAllClients() from your server script, you can send the target part(s) and the positions you want to tween to as a parameter.

Example:
Capture3
Capture

2 Likes

Thanks so much for your quick response! I got it working.