My touched event in my stun stick tool isn't repeating

It just won’t work. It won’t repeat the touched event twice, keeps breaking.

enabled = true

script.Parent.Stun.Touched:Connect(function(cxvxcv)
	if enabled == true then
		enabled = false
		local e = cxvxcv.Parent:FindFirstChild("Humanoid")
		if e ~= nil then
			if e then
			script.Parent.Attack:Play()
			e:TakeDamage(30)
			e.Sit = true
			wait(1)
			enabled = true
			end
		end
	end
end)

1 Like

Try bringing “enabled = true” out of the if statement. Currently if e == nil, the “enabled” value will never be reset back to false

enabled = true

script.Parent.Stun.Touched:Connect(function(cxvxcv)
	if enabled == true then
		enabled = false
		local e = cxvxcv.Parent:FindFirstChild("Humanoid")
		if e ~= nil then
			if e then
			    script.Parent.Attack:Play()
			    e:TakeDamage(30)
			    e.Sit = true
			    wait(1)
			end
		end
        enabled = true
	end
end)
2 Likes