Im trying to make something where a weld gets made then destroyed, but if i try to destroy the weld it makes more, its in a regular script. How do I fix this? Heres the script.
local tool = script.Parent
tool.Activated:Connect(function()
tool.Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local rightArm = hit.Parent:FindFirstChild("Right Arm")
local weld = Instance.new("Weld")
weld.Part0 = tool.Handle
weld.Part1 = rightArm
weld.Name = "Weld1"
weld.Parent = tool
end
end)
end)
tool.Activated:Connect(function()
tool.Weld1:Destroy()
end)

10 comments
it doesnt create more bc of the destroying but bc touched event fires multiple times and that creates multiple welds, if you want the event to fire only once use a debounce or disconnect the event
Basically each time the activated event fires it adds another connection that adds another weld so the second you fire it adds two welds and touched by default already fires mutliple time unless you use a debounce or disconnect the event so it can add like probs like a boatload of welds
and honestly you should merge both the activated events they are same event anyway
How do i disconnect it?
https://developer.roblox.com/en-us/recipes/How-to-disconnect-an-event-connection
Thanks, sorry if im bugging you but how would i use debounce to make it so it would only activate again after the same conditions are met?
https://developer.roblox.com/en-us/articles/Debounce
Thanks again!
Sorry for commenting a bit late but my problem still isnt solved, i dont quite understand how the debouncing thing works for my conditions?
Nvm