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.
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