For my combat system i use a collision, but i need touched function for made it.
My function repeat 2 times or 1 times, i can’t fix it, please help me !
rigHumanoidRootPart.Touched:Connect(function(hit)
if hit.Name == value.BasePart then
if not canAttack then return end
canAttack = false
print("I need help please<3")
end
end)
Is this your entire script? I see you’re attempting to apply a debounce, and something like this for yourself should work properly for that.
local canAttack = true
local cd_duration = 0.5
rigHumanoidRootPart.Touched:Connect(function(hit)
if not canAttack then return end
if hit.Name == value.BasePart then
canAttack = false
task.wait(cd_duration)
canAttack = true
end
end)
You were close. There also might be a problem elsewhere in your script, but we can’t see that.
rigHumanoidRootPart.Touched:Connect(function(hit)
if not rigHumanoidRootPart.CanTouch then return end
if hit.Name == value.BasePart then
rigHumanoidRootPart.CanTouch = false
print("a")
end
end)