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

Why do I have to doubleclick for my tool(light) to turn on?

Asked by 8 years ago
tool.script.Parent

tool.Equipped:connect(function(mouse)
    print("equipped")
    tool.Activated:connect(function()
    print("activated")
        mouse.Button1Down:connect(function()
        print("clicked")
            if light.PointLight.Brightness==0 then
                light.PointLight.Brightness=1
                print("closed")
            else
                light.PointLight.Brightness=0
                print("opened")
            end
        end)
    end)
end)

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

The Activated event is fired when the mouse is clicked while a tool is equipped. So, you're telling it to not turn on until it has been clicked, and then clicked again. The mousedown event is redundant.

tool = script.Parent -- This should also be 'tool =', not "tool." .

tool.Equipped:connect(function(mouse)
    print("equipped")
    tool.Activated:connect(function()
        print("clicked")
        if light.PointLight.Brightness==0 then
            light.PointLight.Brightness=1
            print("closed")
        else
            light.PointLight.Brightness=0
            print("opened")
        end
    end)
end)

0
ohhhhh, derp me. ty Nick1482 50 — 8y
0
No problem. Pyrondon 2089 — 8y
Ad

Answer this question