I’ve been trying to make this sword work, and I’ve now reduced it to the simplest form of a damage script, and not even the sound is playing. My test dummies are npcs, the sword is uncontrollable, please help.
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10,50)
script.Parent.Parent.Parent.Hit:Play()
end
end)
script.Parent.Handle.Blade.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math/Random(10,50))
script.Parent.Parent.Parent.Hit:Play()
end
end)
even if i remove the damage part the sound does not play…
If it’s a SpecialMesh, not a MeshPart, that’d be an issue. Check the error log to see if there’s any errors, that’ll give you more context on what’s erroring. It’s probably the math/Random thing, but there could be other errors too. (You should at least do the bare minimum to try and debug before coming back to say it doesn’t work.)
''''
script.Parent.Handle.Blade.Touched:Connect(function(player)
if hit.Parent == player then
player:FindFirstChild("Humanoid"):TakeDamage(math.random(10,50))
print(TakeDamage)
end
end)
'''
script.Parent.Handle.Blade.Touched:Connect(function(hit)
if hit.Parent then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(10,50))
print("TakeDamage")
end
end)
What is player? You don’t define it anywhere. This is essentially checking if hit.Parent is nil, which doesn’t make sense if it triggered the Touched event.
script.Parent.Handle.Blade.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(math.random(10, 50))
script.Parent.Parent.Parent.Hit:Play()
end
end)
''''
script.Parent.Handle.Blade.Touched:Connect(function(player)
if hit.Parent == player then
player:FindFirstChild("Humanoid"):TakeDamage(math.random(10,50))
script.Parent.Parent.Parent.Hit:Play()
end
end)
'''
Did you check the output for errors? Are you sure the script is even running? It’s hard to say what’s wrong when you aren’t doing anything to try and debug.