Detecting if the player has left clicked

I’m trying to detect if a player has left clicked but my code doesn’t work.

UserInputService.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        warn('clicked')
    end
end)

Had you tried InputBegan?
InputBegan May be better suited to what you are trying?

3 Likes

I personally use game.Players.LocalPlayer:GetMouse().Button1Down instead of UserInputService. You can try that I guess.

(Edit: don’t really try this method, try popgoesme700’s method.)

Do not use this… I’ve read that :GetMouse() is soon to be deprecated.
Could be wrong on this

Use Mouse.Button1Down.
https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Down

what exactly is replacing it?

I don’t think they mean a gui, I am pretty sure they are talking about anywhere on the screen

UserInputService, as a matter of a fact

Ah seems they possibly receded their decision… though i remember them stating they were planning to phase out GetMouse()

Yeah. They deprecated KeyDown I think.

this might be it… my bad…

honestly it makes sense now that I think about it, though I wonder why they receded their decision, they must have a good reason for it

I don’t think its going to be deprecated, they just recommended for you to use UserInputService or ContextActionService.