Can you get the script from an asset/template?

hey there just a quick question can you get an script or acces an script from a asset

Hi @Timme_Kingma,

You can only access the contents of a script asset, that would be a text string of the JS source code:

const code = scriptAsset.resource;

I don’t think that’s what you are asking though, that isn’t of much use.

A script type is instanced after it’s attached to a script component on an entity. From there you can access that instance using this notation:

entity.script.scriptTypeName;

So if the script type name is myScript it will be like this:

entity.script.myScript;
2 Likes

its complicated to explain but i got a spawner and i want to check on the think that i spawn how manny of variable points it got on a script but its an template/asset so in my typescript version it needs to be an entitiy to confurt it into an script otherwise an error but ty m8