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.)
it is a mesh part, and ive fixed the math/Random… and ive been trying to debug for months now
Try:
''''
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)
'''
Correct me if I’m wrong…
few errors in ur script:
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)
Here I edited my script, check again
That would not work.
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.
This is misuse of FindFirstChild and is no better than player.Humanoid
.
What are you trying to do here?? TakeDamage
isn’t a defined variable, this’ll just print nil.
You never close the opening parenthesis for the :Connect
function.
I corrected my script, but thanks for letting me know!
This is regarding the current version.
I think this would work!
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 not work…
Why print(TakeDamage), it ain’t a varaible.
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.
Is there any errors in output?
why do you have a part within a part?
no errors…
Can you provide the whole event section? Perhaps the problems lies there.
@Kamlkaze_Kid You’re attempting to compare the object’s parent against itself, which wont work as you’ve renamed hit
to player
.
EDIT
Oof, don’t know how I missed that code lol. Is the script disabled at all? Or is there something preventing the execution? Have you tried using a print to see what the Touched
listener returns?
in the first post is the whole event unless you want to see my animations
Have you tried:
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)
?