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

Make a tool able to click a click detector?

Asked by 9 years ago

I am trying to make a door that will close when a person with a certain tool clicks on a button. Only one player will have the tool, and they should have it equipped at all times. I can't get the button to work when the tool is equipped.

As of now, it is a part with a click detector inside. I'm not sure if I'm supposed to use MouseButton1Click for this.

local button = script.Parent
door1 = workspace.Doors.Door1

function onClicked(playerWhoClicked)
    local tools = playerWhoClicked.Backpack:GetChildren() 
    for i, tool in pairs(tools) do
        if tool.Name == "MakeItRain" then 
            door1.Transparency = .2
            door1.CanCollide = true
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
Mouse click is correct. I don't think you can activate click detectors with gear, and instead of doing a pairs it's simple just do, "playerWhoClicked.Backpack.MakeItRain". EzraNehemiah_TF2 3552 — 9y
0
Thanks. Would it work with a surface gui? secretassassin3 30 — 9y
0
You should write this into the tool itself and use the Target property and Button1Down event of the mouse and to see what object is clicked. NotsoPenguin 705 — 9y
0
That sounds hard. I guess I could try. secretassassin3 30 — 9y
0
Remote Event? Idk on this. MessorAdmin 598 — 9y

Answer this question