Am I blind or is this a Roblox bug?

Hello, today I have come to ask for help on an issue that has been plaguing my game almost since its creation.

My team has had to create mobile controls so that mobile users can race in our game and still be able to compete. However, there is one problem that has driven many mobile players from our game. When ever people play on mobile, from time to time they will continuously keep turning in the same direction even after they have let go, and this video is evidence for that:

If I need to provide code for our controls I will be happy to, but for now, take a look at this video:

Notice when I tap the button, hold the button, or anything like that it works fine. But when I start pressing inside the button and then come off of it,
This won’t fire:

left.InputEnded:Connect(function()
	leftMouse = false
	game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end)

This won’t fire:

left.InputChanged:Connect(function(input)
	if input.UserInputState == Enum.UserInputState.Cancel then
		leftMouse = false
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
	end
end)

And this won’t fire:

left.MouseButton1Up:Connect(function()
	leftMouse = false
	game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end)

All three ways we have tried to capture the player’s finger leaving the mobile conrtrols, and for some reason, all have failed, why is this? Our code? A roblox bug? I would very much like to know.

1 Like

I have a feeling it might be due to a loop you have, but how does the button get the input?

You could try using a while loop like every 2 seconds to check if players are still pressing the button?

Personally, I think it’s either phone settings or roblox mobile app bug…

Yeah this happens across many different phones and tablets.

Like this

function leftOn()
	local direction = "Left"
	
	left.MouseButton1Down:Connect(function()
		leftMouse = true
		while leftMouse == true do
			game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
			task.wait()
		end	
	end)
end

Try putting the loop outside the MouseButton1Down, it may be that the Connect is replicating when the function is called.

The function leftOn is fired every time a new a player resets so it can lock on to the new UI. If I put the loop outside then it would start immediately.

yep I think that’s it! from what I can understand, you can try fixing by using a left.MouseButton1Up to change leftMouse to false ?

that would break the loop…

But I do in all of these?
characters

1 Like

How so? Is the leftMouse variable already set to true before the player does anything?

1 Like

No, are you proposing this change?

function leftOn()
	local direction = "Left"
	
	left.MouseButton1Down:Connect(function()
		leftMouse = true
		while leftMouse == true do
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
		task.wait()
	end	
	end)
end
function leftOn()
	local direction = "Left"
	
	left.MouseButton1Down:Connect(function()
		leftMouse = true	
	end)
    while leftMouse == true do
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
		task.wait()
	end
end

something like this?

function leftOn()
	local direction = "Left"
	local leftMouse = nil

	left.MouseButton1Down:Connect(function()
		leftMouse = true
	end)

       left.MouseButton1Up:Connect(function()
               leftMouse = false
       end)

while leftMouse == true do
			game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
			task.wait()
		end	

sorry, I forgot a few ends (replying to my reply above)

Oh I already have one for it, and it still doesn’t work

function leftOff()
	local direction = "Left"
	
	left.InputEnded:Connect(function()
		leftMouse = false
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
	end)
	
	left.InputChanged:Connect(function(input)
		if input.UserInputState == Enum.UserInputState.Cancel then
			leftMouse = false
			game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
		end
	end)
	
	left.MouseButton1Up:Connect(function()
		leftMouse = false
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
	end)
	
	left.TouchTap:Connect(function()
		leftMouse = true
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
		task.wait()
		leftMouse = false
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
		wait()
		leftMouse = false
		game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
	end)
end	

leftMouse is a global variable

Yeah, but leave the MouseButton1Down and while loop outside the function

Ok, I see what you are saying, but how would it make a difference if the leftMouse = false won’t fire? I’ll still try it though.

take all the functions inside leftOff() outside of it

1 Like

it fires because it’s in its own thread now. it won’t wait for others to finish to run

1 Like

I have to put them in there though because then the left variable destroy and won’t fire again when a player resets.

1 Like

oh, so the script doesn’t reset, but the UI does?

1 Like