Can scripts be cloned?

Hi,

I am making an npc system and i was wondering if i could clone scripts.

I am making him move randomly – works

The problem is the animation script.

I don’t know how i can put it on the script that clone npc’s because i did’nt make the animation script, its like 1000 lines.

Thank you!

1 Like

I’ve never cloned scripts before, but I imagine they will work fine. I’ve cloned npcs with the script already parented to them, and it still runs.

Basically, yes.

2 Likes

I mean you can copy and paste scripts and duplicate them. Is that what you mean?

Scripts can be cloned.

Keep in mind however, cloning scripts results in a minor performance drop temoprarily as it generates a new context for variables.

A better usecase here to look into ModuleScripts or coroutines

3 Likes