How can i prevent inputs from being registered while a mobile user is scrolling?

Hello all once again! i’m trying to modify a script a friend made to make it work properly for mobile (it was designed specifically for pc), but i’m having some issues:

If i scroll to go down to find more cars, whatever frame i held down on in order to scroll down will spawn the car that belongs to it, so i’m genuinely lost

Here’s some necessary context:

  • It’s a car spawner, that has ViewportFrames with InputBegan to detect input, the issue is that this fires even if a player is just scrolling, there’s very little room on the scrolling gui where there’s nothing that can be clicked on accident.
  • It doesn’t use any image or text buttons, as mentioned above, it has a lot of viewport frames that each have InputBegan linked to them.
  • I thought of doing something like trying to install a double tap system, but was unsuccessful
  • I also tried to make it so it compares the canvassize when input began and when input ended, but that didn’t work either

Here’s the code sample that manages input

v.InputBegan:Connect(function(inputObject)
			if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
				folder:FindFirstChild("Spawn_Event"):FireServer(v.Name,AUTO_DELETE)
				script.Parent.Sound:Play()
				script.Parent.Sound3.Volume = 0
				toggleUI()
				wait(1)
				script.Parent.Sound3.Volume = 2.5
			end
		end)

I might have done my methods the wrong way, so if any of you know how to help me, i’d be very happy to answer any questions, thanks!

You should use a TextButton and then put the ViewportFrame inside the text button.

Yeah i was thinking about doing that, however i wanted to avoid redoing much from the script, i foolishly didn’t realize that all i need to do is change a single line to made it work, thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.