I'm trying to turn this script

local clickDetector = script.Parent
local buttonPressed = false
local ClickModule = require (game:GetService("ServerScriptService").ModuleScript)

local OnClick
OnClick = clickDetector.MouseClick:connect(function(Clicker)
	if not buttonPressed then	
		buttonPressed = true
			ClickModule(Clicker, script.Parent.Parent)
		wait()
		buttonPressed = false
	end
end)

into a left click only detector. I've tried

local clickDetector = script.Parent
local buttonPressed = false
local ClickModule = require (game:GetService("ServerScriptService").ModuleScript)

local OnClick
OnClick = clickDetector.MouseClick:connect(function(Clicker)
	if not buttonPressed then	
		buttonPressed = true
		local Mouse = Clicker:GetMouse()
		local event
		event = Mouse.Button1Down:connect(function()
			ClickModule(Clicker, script.Parent.Parent)
		end)
		wait()
		buttonPressed = false
		event:disconnect()
	end
end)

and it works in studio, but once i run the server, the mouse returns nil and the script doesnt run.

1 comment

0

You could try this method, although it might require the use of Remote Events. https://scriptinghelpers.org/questions/30209/using-getmouse-instead-of-clickdetector