Xbox controls not working:

I’ve a function which allows xbox users to drive:

local function XboxDirection(Input, GameProcessedEvent)
    if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
        if Input.Delta.X > 0 then
            if not CurrentForce then CurrentForce = Vector3.new(0,0,0) end
			CurrentAngle = Vector3.new(0,-1,0) * 2
        elseif Input.Delta.X < 0 then
            if	 not CurrentForce then CurrentForce = Vector3.new(0,0,0) end
			CurrentAngle = Vector3.new(0,1,0) * 2
		end
		
		if Input.Delta.Y > 0.1 then
			if not CurrentAngle then CurrentAngle = Vector3.new(0,0,0) end
			CurrentForce = Vector3.new(-1,0,0)
			print("forward")
		elseif Input.Delta.Y < -0.1 then
			if not CurrentAngle then CurrentAngle = Vector3.new(0,0,0) end
			CurrentForce = Vector3.new(1,0,0)
			print("backward")
		elseif Input.Delta.Y > -0.1 or Input.Delta.Y < 0.1 then
			if not CurrentAngle then CurrentAngle = Vector3.new(0,0,0) end
			CurrentForce = Vector3.new(0,0,0)
			print("stop")
        end
    end
end

However, Since this is tied to inputchanged, There’s a slight problem. when the thumbstick is moved fordward, It prints forward then goes straight back to stop, So to me it seems that the delta value goes back straight to 0 after.

Also, Even when the thumbstick is idle, and no inputs are being used, it still prints “stop” indicating that the input has been changed

Does anyone have any ideas on how to fix this?

Replace this
elseif Input.Delta.Y > -0.1 or Input.Delta.Y < 0.1 then
with nothing but an " else " and check if it works.

1 Like

Hello, Thank you for replying

It’s still doing the same thing, The delta.Y is being set to “0” as soon as delta.Y is set, None of my other scripts are interfering with this and if you request anymore information let me know what i can provide

Looking at it again, the issue is pretty simple. Delta represents the difference between the current position and previous position, so it is 0 since there was no change. Use Input.Position instead.

2 Likes

Oh, It worked. Thank you :+1:
(30chars)

1 Like