Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What function do I need to close? I already closed it

Asked by 4 years ago
Edited 4 years ago

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
0
do not have a .Activated inside a .Equipped HappyTimIsHim 652 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

That's not how you close your functions. You need to have a bracket after your last two ends.

--//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 -- closes line 54
                end -- closes line 52
            end -- closes line 48
            wait(coolDown)
            debounce = false
        end -- closes line 47
    end -- closes line 45
end) -- closes line 17
end) -- closes line 16
Ad
Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago
--//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
end)
end)

Answer this question