(Help) Tool not working

I wrote a simple script, to make it so that when someone touches the lightsaber they take damage, but it isn’t working. Please help me out.

https://gyazo.com/0bb280c40fb592fea20be443a580b5b0

https://gyazo.com/d26643f527fa1e34aea9074c67391886

Your tool will never successfully locate a character because the character is a model (and you are detecting parts inside said character). To fix this, try editing your code so it looks for the character via the following:

script.Parent.Handle.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        hit.Parent.Humanoid:TakeDamage(20)
    end
end)

That is exactly what I wrote. Look carefully.

No, you wrote

game.Players:GetPlayerFromCharacter(hit)

not

game.Players:GetPlayerFromCharacter(hit.Parent)

Oh yea, I totally forgot! Thanks alot!

1 Like