Why does my ragdoll impact plays alot of times

my ragdoll impact plays alot of times heres the clip

the impact script:

local torso = script.Parent.Torso
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA(“Part”) then
torso.Touched:Connect(function(h)
if not h:IsDescendantOf(script.Parent) and script.Parent.euphoria.V.Value == true then

				if v.Velocity.Magnitude >13 then
					if v.Velocity.Magnitude >2 then
			local sou=math.random(1,6)
			local s=script.Parent.im["Impact"..sou]:clone()
			s.Parent=script.Parent.Torso
			s.Name="Impact"
			game.Debris:AddItem(s, 2)
						s:Play()
						end
		
					end
			end	
			
	end)

end

end

1 Like

(Sorry if i post the wrong topic) i dont know how to add Cooldown

1 Like

Also using v.Touched:Connect(Function() it will dectecd the entire body so it will play alot of times

1 Like

Any time you use a Touched event with a player you should use a Debounce – When and Why to stop it from happening a bunch of times. Basically a ‘cooldown’ like you mentioned.

1 Like

Do you have a example?
thanks i will try

1 Like

If you look at the link you’ll see examples.

1 Like

I made a example i will try this

local torso = script.Parent.Torso
local debounce = false
local waitingtime = 0.75
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA(“Part”) then
torso.Touched:Connect(function(h)
if not h:IsDescendantOf(script.Parent) and script.Parent.euphoria.V.Value == true then

			if v.Velocity.Magnitude >13 then
				if v.Velocity.Magnitude >2 then
					if not debounce then
					debounce = true
					local sou=math.random(1,6)
					local s=script.Parent.im["Impact"..sou]:clone()
					s.Parent=script.Parent.Torso
					s.Name="Impact"
					game.Debris:AddItem(s, 2)
						s:Play()
					wait(waitingtime)
					debounce = false
				end
               end
			end
		end	

	end)

end

end

1 Like

it worked it take a little time to play again (I put 11 and its now perfectly fine!!!)

2 Likes

the game is (6) No r15 allowed euphoria ragdoll fan made - Roblox