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

I will not print when the tool is clicked 2 times?

Asked by 5 years ago
Edited 5 years ago

when the tool is activated and click 2 times, I want it to print the stuff I want it to but it won't work

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local starterPack = game:GetService("StarterPack")
local tool = starterPack:WaitForChild("Tool")
if tool then
    tool.Activated:Connect(function(activated)
        if mouse.MouseButton1Click == 2 then
            print("clicked 2 times")
        end
    end)
end

2 answers

Log in to vote
0
Answered by
KDarren12 705 Donator Moderation Voter
5 years ago
Edited 5 years ago

You should use an amount of clicks variable that counts the clicks.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local starterPack = game:GetService("StarterPack")
local tool = starterPack:WaitForChild("Tool")
clicks = 0
if tool then
    tool.Activated:Connect(function(activated)
        if mouse.Button1Down then
            clicks = clicks + 1
        end
    if clicks == 2 then
        print("Clicked two times.")
        clicks = 0
    end
    end)
end
0
It's a small adjustment, but i believe this will work efficiently. KDarren12 705 — 5y
0
@KDarren12 it gave me the error 08:56:55.375 - MouseButton1Click is not a valid member of PlayerMouse bluemountainlion 56 — 5y
0
OH, you can't get a MouseButton1Click from Player's mouse. KDarren12 705 — 5y
0
Let me edit it real quick KDarren12 705 — 5y
0
All you needed to change was "MouseButton1Click" to "Button1Down" KDarren12 705 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Activated is ran whenever you click , use a variable that can be increased to see when they click twice

0
just answered based on your answer KDarren12 705 — 5y

Answer this question