So i have this sword tool that has a attack script and when you touch a chicken it adds a intvalue but it creates a new value every time you touch the chicken i want it to just create one value even if you touch it multiple times
Heres the script
function Sword:Connect()
Handle.Touched:connect(function(hit)
local myPlayer = GLib.GetPlayerFromPart(Tool)
local character, player, humanoid = GLib.GetCharacterFromPart(hit)
if myPlayer~=nil and character~=nil and humanoid~=nil and myPlayer~=player then
local isTeammate = GLib.IsTeammate(myPlayer, player)
local myCharacter = myPlayer.Character
local myHumanoid = myCharacter and myCharacter:FindFirstChild'Humanoid'
if (Config.CanTeamkill.Value==true or isTeammate~=true) and (myHumanoid and myHumanoid:IsA'Humanoid' and myHumanoid.Health > 0) and (Config.CanKillWithForceField.Value or myCharacter:FindFirstChild'ForceField'==nil) then
local doDamage = Config.IdleDamage.Value
if Sword.State == 'Slashing' then
doDamage = Config.SlashDamage.Value
elseif Sword.State == 'Lunging' then
doDamage = Config.LungeDamage.Value
end
GLib.TagHumanoid(humanoid, myPlayer, 1)
humanoid:TakeDamage(doDamage)
-- The thing that i want debounced
local dm = Instance.new("IntValue", humanoid)
dm.Name = "DamageTaken"
local pl = Instance.new("StringValue", dm)
pl.Name = plr.Name
end
end
end)
end
