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

How to activate script using left mouse click and not right mouse click?

Asked by
snarns 25
7 years ago

It's a script that simply makes a decal visible/invisible on a brick with a ClickDetector. However, it activates using both left click and right click. How do I make it activate using only the left mouse click?

local isOn = true

function on()
 isOn = true
 script.Parent.Decal.Transparency = 0
end

function off()
 isOn = false
 script.Parent.Decal.Transparency = 1
end

function onClicked()

 if isOn == true then off() else on() end

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

on()

I've tried using [script.Parent.ClickDetector.MouseButton1Click:connect(onClicked)] for line 19 but then the script doesn't work at all.

0
MouseButton1Click did not work because it's only usable on GUI's. From what I found. MouseClick, MouseHoverEnter, and MouseHoverLeave seemed to be the only action events you could use with a ClickDetector. There might be a way though that I'm not aware of. Troidit 253 — 7y

Answer this question