mouse.Button1Down not firing

I’m creating a leaf blower to blow leaf monsters apart, but the mouse events doesn’t seem to be firing. I’m using a script, not a localscript. I don’t see any errors about this in the developer log.

Can anyone tell me why?

repeat wait() until game:IsLoaded()
local mouse = script.Parent.Parent.Parent:GetMouse() -- Gets mouse from player
local a = false

script.Parent.Equipped:Connect(function()
	a = true
end)

script.Parent.Unequipped:Connect(function()
	a = false
end)

mouse.Button1Down:Connect(function() -- Doesn't seem to be firing this function
	if a == true then
		script.Parent.wind.wind.Volume = 1
		script.Parent.killpart.Script.Disabled = false
		script.Parent.wind.ParticleEmitter.Enabled = true
		script.Parent.wind.wind:Play()
	end
end)

mouse.Button1Up:Connect(function()
	if a == true then
		script.Parent.killpart.Script.Disabled = true
		script.Parent.wind.ParticleEmitter.Enabled = false

		for i = 1, 0, 0.1 do
			script.Parent.wind.wind.Volume = i
			wait(0)
		end
		script.Parent.wind.wind:Stop()
		script.Parent.wind.wind.Volume = 1
	end
end)
1 Like

What’s the script’s parent’s parent’s parent?

The scripts parent’s parent’s parent is the player.

What is button Up? The most likely scenario based on your situation is a somehow being false.

The button up is the event when the player releases the left mouse button.

1 Like

Is your script Server Sided or Client Sided?

GetMouse doesn’t support global scripts unfortunately. my solution would be putting the code in a local script and make remote events that would be fired by global scripts when you click.

The code would probably look like this:

-- local script
repeat wait() until game:IsLoaded()
local mouse = game.Players.LocalPlayer:GetMouse() -- Gets mouse from player
local a = false

script.Parent.Equipped:Connect(function()
	a = true
end)

script.Parent.Unequipped:Connect(function()
	a = false
end)

mouse.Button1Down:Connect(function() -- Doesn't seem to be firing this function
	script.Parent.button1downevent:FireServer()
end)

mouse.Button1Up:Connect(function()
	script.Parent.button1upevent:FireServer()
end)
-- global script
local a = true

script.Parent.button1downevent.OnServerEvent:Connect(function()
	if a == true then
		script.Parent.wind.wind.Volume = 1
		script.Parent.killpart.Script.Disabled = false
		script.Parent.wind.ParticleEmitter.Enabled = true
		script.Parent.wind.wind:Play()
	end
end)

script.Parent.button1upevent.OnServerEvent:Connect(function()
	if a == true then
		script.Parent.killpart.Script.Disabled = true
		script.Parent.wind.ParticleEmitter.Enabled = false

		for i = 1, 0, 0.1 do
			script.Parent.wind.wind.Volume = i
			wait(0)
		end
		script.Parent.wind.wind:Stop()
		script.Parent.wind.wind.Volume = 1
	end
end)

what it would look like in tool: image

this probably isn’t the most inefficient way of doing it, but if it works, it works.

here:

local player = game.Players.LocalPlayer
player:GetMouse().Button1Down:Connect(function()
—Do stuff
end)

Also why do you handle your events within the tool itself? I do remote it in serverscriptservice

I didn’t notice you used :GetMouse sorry :neutral_face: