Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

ohhhhh, derp me. ty

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.