so i want to write a script that renders the objects based on the data the server sends to the client
however, i don’t know how i’m supposed to make it know when to delete, tween it, etc, when the server object moves. And i’m also wondering if what i’m doing is efficient at all (writing out a bunch of lines of code that refer to just 1 table), or if there’s another way to do this. thanks.
more specifically, i want to write an over-arching function that can be utillized to create any object (rendering it) on the client, based off the data the server sends (via remote-event atm)
So at its very VERY basic form, you want to create a function that renders an object that is sent to it by the server(On the client)? And on the server, you want to send the client this object every time it moves server-sided? Have you attempted anything yet? Or have a plan? I just want to know where I should be looking to help you.
Just from your question I don’t know how I'm supposed to make it know when to delete, tween it, etc, when the server object moves you can set up an AncestryChanged connected to the instance you are keeping track of(Or instances). Then if the Instance is removed check in the AncestryChanged if the instance is a DescedantOf game. As for the Tween, you can just check if the Instance’s position has changed using GetPropertyChangedSignal. Then under each of these signals, you can fire a remote event communicating to the client that it was removed, or the instance moved. Then on the Client just update the Instance.
I don’t know if that is exactly what you wanted but if not it’d be cool if you could elaborate a little more.
Not 100% sure what he wanted but this could be of use regarding the tweening part of your reply? Link: TweenService V2 (essentially just tweens the parts on the client and positions them on the server)
for example, let’s say i made a spellbook and i wanted it to follow you while equipping it, but on the server this looks bad whenever you move (it jitters a lot). to get smooth animations, you generally do it on the client, but then others can’t see it, so this kind of function would allow all clients to make whatever object whenever the server fires them (via a remoteevent) the info needed to construct such an object.
Why do other players need to see that change? Is there a reason you can’t just update it from each client? Then, each client will see the book facing them.