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

Left click mouse not working properly any help?

Asked by 9 years ago

Its not working correctly, can anyone help?

Note: I need this to be on left click.

function LeftClick(mouse)
end
function GetLeftClick(Mouse)
    script.Parent.Main.Transparency = 1
    script.Parent.Main.Knife:Play()
    local Connection = nil
    local Blade = Instance.new("Part")
    Blade.BrickColor = BrickColor.new("Really black")
    Blade.Name = "Blade"
    Blade.CanCollide = false
    Blade.FormFactor = Enum.FormFactor.Custom
    Blade.Size = VEC3(0.5, 2.5, 1)
    local Mesh = Instance.new("SpecialMesh")
    Mesh.MeshId = S.KnifeMeshId
    Mesh.MeshType = Enum.MeshType.FileMesh
    Mesh.Scale = VEC3(0.7, 0.7, 0.7)
    Mesh.TextureId = S.KnifeTextureId
    Mesh.Parent = Blade
    Blade.Parent = Gun_Ignore
    local BladeWeld = Instance.new("Weld")
    BladeWeld.Part0 = Blade
    BladeWeld.Part1 = FakeLArm
    BladeWeld.C0 = CFANG(RAD(-90), 0, RAD(180))
    BladeWeld.C1 = CF(0, -1, 0.75)
    BladeWeld.Parent = Blade
    Connection = Blade.Touched:connect(function(Obj)
        if Obj then
            local HitHumanoid = FindFirstClass(Obj.Parent, "Humanoid")
            if HitHumanoid and IsEnemy(HitHumanoid) then
                local CreatorTag = Instance.new("ObjectValue")
                CreatorTag.Name = "creator"
                CreatorTag.Value = Player
                CreatorTag.Parent = HitHumanoid
                HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
                MarkHit()
            end
        end
    end)
    TweenJoint(LWeld2, CF(), CFANG(0, RAD(90), 0), Linear, 0.05)
    TweenJoint(LWeld, ArmC0[1], CF(-0.1, 0.2, -0.1) * CFANG(0, 0, RAD(-20)), Linear, 0.05)
    TweenJoint(RWeld, ArmC0[2], CFANG(RAD(-30), 0, 0), Linear, 0.1)
    TweenJoint(Grip, Grip.C0, CF(), Linear, 0.1)
    spawn(function()
        local Force = HRP.CFrame.lookVector * 8e4
        local BF = Instance.new("BodyForce")
        BF.force = Force
        BF.Parent = HRP
        delay(0.03, function()
            BF.force = -Force / 2
            wait(0.03)
            BF:Destroy()
        end)
    end)
    wait(0.05)
    RotCamera(RAD(6), 0, true, 0.1)
    delay(0.1, function()
        RotCamera(RAD(-2), 0, true, 0.05)
    end)
    TweenJoint(LWeld, ArmC0[1], CF(0.8, 1.7, 0.2) * CFANG(0, 0, RAD(-80)), Linear, 0.06)
    wait(0.2)
    Connection:disconnect()
    wait(0.2)
    TweenJoint(LWeld2, CF(), CF(), Linear, 0.15)
    TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Linear, 0.15)
    TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Linear, 0.15)
    Blade:Destroy()
    script.Parent.Main.Transparency = 0
end
GetLeftClick()
0
Wouldnt Button1Down give the same effect? pluginfactory 463 — 9y
0
For left Click, Button2Click function would work :/ pluginfactory 463 — 9y
0
how would i do it CarterTheHippo 120 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

By the looks of the code it appears your working with a tool. First we need detect when your tool is equipped, both to get the mouse and to run the relevant code.

To do this you first need to get the tool. More than likely your script is parented directly to the tool, so local tool = script.Parent would be the tool. Now to detect when the tool is equipped, to do this we use the Equipped event. The Equipped event also passes the mouse as an argument, this is how we'll be able to detect a Left Click.

local tool = script.Parent 

function ToolEquipped(mouse) 
    mouse.Button1Down:connect(function() --An anonymous function for convenience.
        print("Left Click")
    end)
end

tool.Equipped:connect(ToolEquipped) 

Left Click will be displayed in the output when left clicking with the tool equipped. I hope there's more to your script because I notice some undefined functions.

0
there is much more to the script, I couldnt fit it all into one thing [Too Big] CarterTheHippo 120 — 9y
0
Works great! Now i just need to get a cool down in there so you cant spam it :p CarterTheHippo 120 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

It appears to be a tool, and there's multiple ways to go about doing this, but i would recommend doing the activated function.
Example:

tool = script.Parent
tool.Activated:connect(function()
    print("Left Click")
end)

Answer this question