CollidePart = script.Parent
CollidePart.Touched:Connect(function(Part)
if CollidePart.CanCollide == true and Part.Parent ~= script.Parent.Parent and Part.Parent.Parent ~= script.Parent.Parent and not Part.Parent:FindFirstChild("Humanoid") then
print("working")
script["Sword Hit"]:Play()
end
end)
a tool with no "Handle"part but it have other part for being held.
this script is in Tool.CollidePart and this script have a sound named “Sword Hit”
If you don’t want it to play the sound so many times like that
Debounce
local debounce = false
script.Parent.Touched:Connect(function(hit)
if debounce == false then
if hit.Parent ~= script.Parent.Parent then
script["Sword Hit"]:Play()
debounce = true
script.Parent.TouchEnded:Connect(function(hit2)
if hit == hit2 then
debounce = false
end
end)
end
end
end)
This is caused by a behind the scenes action performed by Roblox’s internal engine, when the tool is dropped into the workspace its handle’s .Touched event gets overridden and connected to a function which allows for the tool to be picked up again once its handle is touched.