Why is UserInputService only printing once?

When I press MouseButton1, its supposed to print “Fired”, it only prints it once even though I’m clicking multiple times. Heres a video

robloxapp-20210121-0913196.wmv (325.7 KB)

And heres my script (local script btw):

userInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Fired")
	end
end)

Could you try using ContextActionService

local function Fire(_, inputState)
	if inputState ~= Enum.UserInputState.Begin then return end
	print("Fired")
end

game:GetService("ContextActionService"):BindAction("GunFire", Fire, false, Enum.UserInputType.MouseButton1)
2 Likes

Try using InputEnded, instead of InputBegan.

2 Likes

I tried that, if i stop clicking then it wont print the next time i click

1 Like

No different, still doesnt work

1 Like

Try this

local localPlayer = game.Players.LocalPlayer
local mouse = localPlayer:GetMouse()
mouse.Button1Down:Connect(function()
    print('clicked')
    -- code here
end)
1 Like

I’ve noticed recently using UserInputService to run the controls for my construction vehicles (arms, scoops, lifts etc.) that the controls won’t quit operating when you release the inputs.
This seems to be working with VehicleSeats as well, as in, you’ll be driving along, release the W key, and the vehicle keeps moving forward like you had W pressed down.
I haven’t been able to trace it to my scripts, or lag or anything else since I hadn’t changed anything in the scripts. The scripts also look for an InputChanged to start the function, not a while true loop.

1 Like

I seem to have got it working now? I have no idea how but I just started scripting more and now it works I guess?