[SOLVED] Separating cloned entities

I have an entity with a health bar, and when I clone it and destroy the clone’s health bar, the main one gets its health bar destroyed. also, I did Monster.parent.addChild but it’s the same. It’s as if the script is linked together.

It’s a bit hard to diagnose the problem with a reproducible case to inspect. Can you share a project URL with accompanying steps to reproduce?

the spawner script is in wall 2,
wasd to move space to schoot

the health bar is not moving down now any ideas?

It looks like your HealthBar.js script isn’t actually assigned to any script component:

image

Do you see that little circle to the left of the asset name HealthBar.js? That is an indicator to say that the asset isn’t directly referenced by anything in the hierarchy. This is documented here:

https://developer.playcanvas.com/en/user-manual/designer/assets/#checking-references

i set it up so at runtime it will be put onto the monster, so i have to give it to something for it to be transferred at runtime? ill try, no that didnt work

Oh, I see. I was going to take another look but the URL link has disappeared.

ok i got it to work, now my monster3 wont take dmg any ideas

It doesn’t look like the health bar script is attached to any entities in the project :thinking:

I would recommend branching or forking the project and just get the player and one monster working to work out what is causing the bugs.

i solved it, i had the healthbar script get attached after the clone was made