How would I make a script detect if there is a clone of itself?

Hey so, I have a bit of a strange question, It’s kinda hard to explain.

Basically, I have a part that when touched, clones a script into the player’s character and enables it

The problem is, If for some reason, the player touches the block twice after it’s cooldown, I want the cloned script to detect that the player already has a script, and so, destroy itself.

I’ve tried to check if the player already has that script using if player:FindFirstChild(script.Name) then

But doing so will make the script find itself and just destroy itself even if there arent 2

(I know I could just make the touching part check if the player already has the script, and then not clone it, but I SPECIFICALLY need it to be like this for some other stuff I plan to do)

Is there any way to do this? or should I just give up my idea?

In that script, use child added events whenever a new instance is added inside the character model.

1 Like

You can make the script rename itself if it doesn’t already exist.

if script.Parent:FindFirstChild("scriptNewName") then
   script:Destroy()
end
script.Name = "scriptNewName"
1 Like

Please don’t clone scripts into things. That’s a really janky design pattern. There’s virtually nothing that you can create with script clones that you can’t create with nominal design solutions. Could you elaborate more on what this “other stuff” is so we can give a better solution?

2 Likes

Thanks, I hadn’t thought of that!

Thanks, I’m aware It isn’t ideal, still, I wanna see the results I get this way.

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