I have closed function but it keeps asking me to close it, what do I do? The function that I need to close is at Line 17
--//Variables
local tool = script.Parent.Parent
local hole = tool.Hole
local handle = tool.Handle
local debounce = true
local config = tool.Config
local range = config.Range
local dmg = config.Damage
local coolDown = config.CoolDown
local clips = config.Clips
local ammo = config.Ammo
local maxAmmo = config.MaxAmmo
local allowTracing= config.AllowTracing
--//Events
tool.Equipped:Connect(function()
tool.Activated:Connect(function(mouse)
if debounce then
--//Doesn't allow spamming
debounce = false
--//Ray Get, Set
local ray = Ray.new(hole.CFrame.p (mouse.hit.p - hole.CFrame.p) * range.Value)
local hit, position = workspace.FindPartOnRay(ray, plr.Character, false,true)
end
if allowTracing.Value == true then
--//Make part
local trace = instance.new("Part",workspace)
trace.Material = Enum.Material.Neon
trace.BrickColor = BrickColor.new("Black")
trace.CanCollide = false
trace.Anchored = true
trace.Transparency = 0.5
--//Show Direction
local distance = (hole.CFrame.p - position).magnitude
trace.Size = Vector3.new(0.2,0.2, distance)
trace.CFrame = CFrame.new(hole.CFrame.p, position)* CFrame.new(0,0,-distance/2)
--//Remove debris
game:GetService("Debris"):AddItem(trace, 0.1)
end
--//Hit Detection
if hit then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
if hit.Name == "Head" then
--//Double damage on headshots
humanoid:TakeDamage(dmg.Value*2)
--//Walkspeed slower when hit on legs
if hit.Name == "Left Leg" then
humanoid:WalkSpeed(-2)
if hit.Name == "Right Leg" then
humanoid:Walkspeed(-2)
else
--//Normal damage on body shots
humanoid:TakeDamage(dmg.Value)
end
end
end
wait(coolDown)
debounce = false
end
end
end

1 comment
do not have a .Activated inside a .Equipped