How to make my game compatible for tablet+phone?

So I have a blast system in my game, which uses on touch for the blasting:

UserInputService.InputBegan:Connect(function(inputObject, gameProcessed)
    if inputObject.UserInputType == Enum.UserInputType.MouseButton1 or inputObject.UserInputType == Enum.UserInputType.Touch or inputObject.UserInputType == Enum.UserInputType.Gamepad3 then
		local data = GetData(plr)
		if not gameProcessed and data then
			if data.GameData.ShootingMode.Value == true then
				if plr.Character then
	        		Held = true
					repeat game.ReplicatedStorage.Remotes.Blast:FireServer(m.Hit) wait() until Held == false
				end
			end
		end
    end
end)

The problem is that on phone and tablet, the blasting barely works, especially on phone. It usually fires toward where the player’s joystick is, but no where else. This gets annoying for mobile players. Is there any way I can fix this?

1 Like

That would be because you are using mouse.Hit. You are not supposed to be using mouse objects for mobile devices that don’t have a mouse!

See: ViewportPointToRay. There are many threads on the DevForum about working with this function over using mouse.Hit for certain systems. Worth a good search.

1 Like

Yes, as @colbert2677 said, mouse will not work in this case. The reason that it is firing towards the joystick is because the player is constant tapping on it, thus, the game thinks that the “mouse” is at the joystick and it fires there.

1 Like