Mobile gun firing when dragging thes screen, not when clicking only

  1. What do you want to achieve? Keep it simple and clear!

Make gun not fire when moving the screen on mobile.

  1. What is the issue? Include screenshots / videos if possible!

The “Button1Down” event doesn’t recognize dragging.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

None.


Code for firing:

Mouse.Button1Down:Connect(function()
	MainModule.ButtonDown(Settings, Clone, Character, Mouse, Camera ) -- this has a module that sets "MouseDown" to true 
end)

Mouse.Button1Up:Connect(function()
	MainModule["MouseDown"] = false
end)

Issue:

you could make it so if the mouse moves a certain amount after mouse down (player holding finger), it will not shoot since that means the player is dragging their finger. but if the mouse doesn’t move much, it will count as the player not dragging and when the player releases their finger, mouse up, it will shoot.

i hope this makes sense for you (as you can tell i’m not that good at explaining)

I think the easiest method would be to have a fire button
Most of the major mobiles games out there ( cod fornite pugb ) does that

I tried that, but then raycasting doesn’t work (Raycast needs Mouse Position and when you click the button the mouse position is the place where the user has clicked).

If you are going to use a button, it’s probably better to have the crosshair always in the middle.
You can use
ScreenPointToRay
Method instead

Edit
Fixed the link

1 Like

Tried, but didn’t really get how it works. Thanks tho, might be helpful, I’ll mess with it a bit more.