I’m making an airplane and need the aerodynamics calculations to run on the owner of the assembly (be it the server or a client) so that the simulation is smooth. How do I make a script that understands the context in which it should run like this?
I think you’d want to look in to the network ownership API.
I had actually already implemented a system that grants ownership of the model to the client when they sit in the driver seat–I just hadn’t realized that granting ownership just allows the client to tell the server anything about the assembly. My main issue, though, was that the aircraft still needs an aerodynamics simulation when the player isn’t driving, which would basically require me to create two nearly identical scripts on the client and server (ick). I was searching for a better way to have similar functionality when the assembly is owned by either the client or server.
I’m working on something identical to what you described. My solution was to put the code that simulates the aerodynamics in a function in a ModuleScript and then calling that function from the server or client depending on who has network ownership.
That’s exactly what I started doing, too! Still wish there was a way to make scripts that could have their runtime transferred between the client and server, but still nice that ModuleScripts works.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.