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

How to determine if a Player has clicked Button1 twice?

Asked by 10 years ago

So,I tried to make a way so I can see if a player has pressed Button1 twice using a debounce (Line 26) called "Clicked",but it didn't work.

Is there any other way to see if a Player has double clicked Button1,if so how?

---------------Vairbles---------------
local Tool = script.Parent
local Handle = script.Parent.Handle
local Player = game.Players.LocalPlayer--Gets LocalPlayer(which is the player with tool or script)
local PlayersMouse = Player:GetMouse()--Gets the Players mouse with the GetMouse() method
---------Equiped Function----------
    Tool.Equipped:connect(function(Mouse)
------------Coroutine.create---------------
ClickDectector = coroutine.create(function()
        Mouse.Button1Down:connect(function()
            Mouse.Move:connect(function()
                local Distance = (Mouse.Origin.p - Player.Character.Torso.Position).magnitude
                print("Distance From Player:"..Distance)
                if Distance > 21  then
                    local Part = Instance.new("Part",game.workspace)
                        Part.CFrame = CFrame.new(Mouse.Origin.p)
                    Handle.BrickColor= BrickColor.new("Bright green")
                else
                    print("Nope,Nope,no bricks for you")
                    Handle.BrickColor = BrickColor.new("Bright red")
                end
            end)
        end)
    end)
--------------------------------------------
Mouse.Button1Down:connect(function()
        Clicked = true
    if not Clicked then
    ---False statement--
    print("Clicked is currently :",Clicked,"in other words Off.")
        Handle.BrickColor = BrickColor.new("Meduim stone grey")
        coroutine.yield(ClickDectector)
        Clicked = false
    else
    ---True statement--
        print("Clicked is currently :",Clicked,"in other words On.")
        coroutine.resume(ClickDectector)
    end
end)
end)

1 answer

Log in to vote
0
Answered by
x1op 0
10 years ago

make a variable called mouseClicks with value 0 and once the player presses the button1 make it add one to it and do whatever you want to do with it later then...

Ad

Answer this question