can i dynamically add script to prefab when instantiate?

Hi everyone, i am making a online game and now i can instantiate a prefab(player)when someone login.

while after the prefab instantiated, i can control every prefab at the same time

I have search on the internet and some suggest use Photon.myView(something like that)

but i find that is for Photon cloud only (i am using Photon server instead).

so i have think a solution that, remove the characterContorl script so that i won;t be able to control the others character.

also i should add an script that can receive data from severe and move them.

are there anys ways?

thank you

It is definitely possible to add a script to an instantiated prefab. It’s as simple as:

gameObject.AddComponent("Script Name");

Keep in mind that if you have any public variables assigned in the script you will also need to assign them in the code instead of the normal drag-and-drop procedure when performed in the editor!

–Dep