How would I make this line of code work for mobile and console?

I found this in a free model and its the reason why my game doesn’t work on mobile or console. can anyone explain to me how I could fix it?

this is used in a camera script.

code:

	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness

		local X = TargetAngleX - delta.y 
		TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X 
		TargetAngleY = (TargetAngleY - delta.x) %360 
	end
1 Like

Use

RunService:BindToRenderstep

1 Like

I don’t understand.

here is more code if needed:

input.InputChanged:connect(function(inputObject)
	
	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness

		local X = TargetAngleX - delta.y 
		TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X 
		TargetAngleY = (TargetAngleY - delta.x) %360 
	end	
	
end)

I found out the reason why. It’s because mobile and console don’t have mouse movements, so I need to figure out a way to get thumbstick movement and screen movement

1 Like
local function update()
        local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness

		local X = TargetAngleX - delta.y 
		TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X 
		TargetAngleY = (TargetAngleY - delta.x) %360 
end

game:GetService("RunService"):BindToRenderStep("CameraThing", 1, update)
1 Like

I’m sorry but I don’t think you are understanding. I need the script to work for mobile and console.

also these answers seem very ai generated

1 Like

you can use Enum.UserInputState.Changed instead of mouse movement i think

1 Like

Oh thanks everyone for the help, but I just realized the script completely broke another part of my game! I must now make a new system.

2 Likes

If you plan on trying to take input again for controller, though it’s from 2019, here’s a thread where various issues were tackled:

Make sure there’s a deadzone for controllers, Roblox at that time apparently had 0.2 for theirs. Maybe you want your vectors in your code to be zeros. Some info might be outdated, but hope that helps. Maybe C_Corpze can jump in here.

As for Touch, I’m not sure. There’s likely another thread on the forum for that. I’d assume you can use the TouchGui from Roblox (a screen gui only automatically added if the player has touch input). There’s the camera UI stuff in there. There’s probably a far better way though.

2 Likes

Oh thanks man! I found a different post going into detail on it. I had it working until

:slightly_smiling_face:

1 Like