if Explosion.Touched:Connect(function(plr) if AmmoD == 1 then if game.Players.LocalPlayer.Name ~= plr.Parent.Name then game.Workspace:FindFirstChild(plr.Parent.Name).Humanoid:TakeDamage(3) end end AmmoD = AmmoD - 1 end)
It worked and damaged the player but it only worked once and I was left with the error
I think I found your issue. First of all, you can't use an if statement on the first line of your code.
Secondly, I'm guessing this script is for a weapon, and line 3 is supposed to stop a player from damaging themselves. Therefore at line 3 of your script, if it isn't this isn't running on a local script, the 'LocalPlayer' won't be a valid variable. Therefore I would change line 3 to:
if game.Players:FindFirstChild(weaponHolder) ~= plr.Parent.Name then
The variable weaponHolder would be the string name of the player who has fired the weapon. You can change this to the variable you are using.
Another thing I saw that could be a potential issue is that Explosions don't use .Touched, they use .Hit to recognise a part that is in the radius of it. Therefore, if you are using Explosions, change line 1 to:
Explosion.Hit:Connect(function(plr)
Hope this helps
Tweakified