So basically whenever you hit the player you can keep on clicking the weapon which deals damage, I want it so you can only deal the damage 1 time if the weapon is activated?
Any Ideas Why My Script Is Doing This?
server script in Tool
Av = script.Parent.DamageValue.Value --Attack Value local CanDamage = script.Parent.CanDamage tool = script.Parent function tagHumanoid(humanoid,killer) if humanoid and killer then local tag = Instance.new("ObjectValue") tag.Name = "Killer" tag.Value = killer tag.Parent = humanoid end end script.Parent.Activated:Connect(function() CanDamage.Value = true if script.Parent.Handle.Touched then script.Parent.Handle.Touched:Connect(function(p) local plr = game.Players:GetPlayerFromCharacter(tool.Parent) if script.Parent.CanDamage.Value == true and p.Parent:FindFirstChild("Humanoid") then script.Parent.CanDamage.Value = false local humanoid = p.Parent:FindFirstChild("Humanoid") humanoid:TakeDamage(Av) tagHumanoid(humanoid, plr) wait(.2) script.Parent.CanDamage.Value = true if p.Parent.Humanoid.Health < 1 then print("Player Has Died") end end end) end end)
What MrLonely1221 said is right. You state
wait(.2) script.Parent.CanDamage.Value = true
after setting CanDamage.Value to false, thus you can deal damage every 0.2 seconds. To fix this, just never set CanDamage.Value to true. Only do it in the beginning of your function, like you have.
Further more your indenting scares me. http://blackmiaool.com/lua-beautify/ can help you learn how to indent and make your code 10x prettier.