How to script object being controllable by a player?

Hi everyone. Not sure if the tittle gives the right hint about my question, but I’ll try in full.


I have this camera mesh and I want it to be controllable when proximity prompt, by a player. Basically I want player to interact with the camera, play that pose/animation from the picture, and for player to move it around with AWSD keys (something like pushing it).
Does anyone have any detailed idea how to do that? I would appreciate it a lot

Thank you so much in advance!

1 Like

First thing you would do is setting the network authority to the player, because if the player is the one controlling the thing, it should have replication authority (server won’t interrupt or talk things)
camera:SetNetworkOwner(controllingPlayer)
When player stops using the camera, use the same command and set it to nil which tells server that the meshpart now belongs to the server again.

About the pushing, I’m not sure if you know how to do that or you’re asking how to implement that as well. But basically what you have to do is to set CFrame of the Camera to be always infront of the player, you could try this simple solution camera.CFrame = controllingPlayer.Character.HumanoidRootPart * CFrame.new(0, 0, -6) and tweak it a little bit how you desire. What it basically does that it takes player’s transform data (position and rotation) and multiplies it with new CFrame which has Z value set to -6, which is also called Forward Vector multiplied by -6. It’s forward vector because the value will be translated relatively to player’s CFrame.

Hey, thank you so much for your reply and explaining how to do it. I will try it and let you know about it! Appreciate it a lot.