function dropcore2(name) local drop2 = game.ReplicatedStorage:FindFirstChild(name2.Text):Clone() drop2.Parent = game.Workspace end
the above script works sort of okay. every time i use it, it happens like this:
used once: _ the underscore is a part
used twice: _ _
i use :Destroy() on them right after the part gets made
used 13 time _ _ _ _ _ _ _ _ _ _ _ _ (13 underscores)
it keeps cloning the item more and more, each time i use it. so i use it once, then destroy them. the second time i use it, it makes 2 parts, i destory those, and the third time i use it, it makes 3. It doesn't overwrite the clone. It's like the clone gets stored somewhere, and every time a new one is done, it clones all of the clones in that storage area.I don't know how to fix this, because it SHOULD be replacing the clone, not making more and more copies of it. I hope i explained this well enough.
\/ is what fires it, and it's not anything with dropcore1().
script.Parent.MouseButton2Click:connect(function() dropcore1(script.Parent) frame.yes.MouseButton1Click:connect(function() dropcore2(script.Parent) end) end)
Your connections are connecting connections
She sells sea shells on the sea shore.
Every time script.Parent.MouseButton2Click
is fired, you make a new connection for when frame.yes.MouseButton1Click
is fired. Unfortunately, it appears given the small amount of code in the snippets that frame.yes
is immutable, and therefore probably has an event connection by the time a new one is made.
This is an issue, because when the event is fired after it has been connected twice, your dropcore2
function is being run twice. To solve this, just move your connection outside of the event subscriber:
script.Parent.MouseButton2Click:connect(function() dropcore1(script.Parent) end) frame.yes.MouseButton1Click:connect(function() dropcore2(script.Parent) end)
This results in frame.yes.MouseButton1Click
only having one connection for it, meaning that every time it is fired, dropcore2
is only fired once. That's great news for you.
On a probably unimportant sidenote, I noticed something else about your code that bugs me - dropcore2
never uses its argument, as you name the parameter name
but the closest variable being referenced is name2
. You might want to tidy that up.