Whats supposed to happen in this localscript inside a localscript which is inside a handle for a tool is that it makes the UpperTorso do damage to a player. It is successful but after the tool is activated and the animation and everything is done, the UpperTorso still continues to dasmage players on touch. Can someone rewrite my script to fix this problem?

local plr = game.Players.LocalPlayer
local tool = script.Parent.Parent.Parent
Active = false
tool.Activated:connect(function()

if Active == false then
  Active = true
  plr.Character.UpperTorso.Touched:Connect(function(part)

  local C = plr.leaderstats.Calories
  local Dmg = script.dmg.Value
  wait(.5)
  if part.Parent:findFirstChild("Humanoid") then
    local hum = part.Parent:findFirstChild("Humanoid")

    hum:TakeDamage(Dmg)
  end
  end)
  wait(1)
  Active = false
end
end)


4 comments

0

First of all use :Connect and indent properly

0

Secondly, set Active to false outside of the first if statement

0

is there a way i can make roblox scripts indent my stuff properly for me?

0

Also how do you mean? Where should i do the wait and Active = false, which line?