Script doesn't work on clones?

Hello. I’m making a game where a random world spawns every time I start it. And in this world randomly spam trees and stones. But if the stone and the tree come into contact, the stone is erased. Or if a tree and another tree come into contact, both are deleted. But this doesn’t work.When I started another project to test, I noticed that the script worked in the original object but not in the clone. Is there a way to transfer the script to clones?

I generally used google translate. Sorry.

Since it’s a separate scene couldn’t you use instantiate instead of duplicate?

1 Like

Unfortunately nothing changes

Any errors?

1 Like

No The script just doesn’t work

Show the code where you create the clones?

Hmm. I can’t see any problem with how you’re instantiating it… Perhaps the problem is with the signal connection? You could try adding to kaya.gd:

func _ready():
    body_entered.connect(_on_body_entered)

Another thing you can try is to add something like print("testing") to the _ready function of kaya.gd, to check if that runs at all.

1 Like

Yes, it worked when I wrote it to test. But deletion still doesn’t work. How do I use this code you gave me? With “if”?

I finally did it. I’ve been trying for over 4 hours because I didn’t see a stupid mistake. Many thanks to everyone who helped.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.